storybook: Seeing an odd warning about a missing package.json (that isn't missing)

Describe the bug When building Storybook, I’m seeing a line in the output about a missing package.json for one of my dependencies. Normally I wouldn’t think that this was a Storybook issue, but I’m not seeing this warning from any other tool (including yarn and webpack). Also, the file totally exists, so I’m not sure what the problem is.

To Reproduce Steps to reproduce the behavior:

  1. Build Storybook

Expected behavior No warnings.

Screenshots image

System

Environment Info:

  System:
    OS: Windows 10 10.0.19042
    CPU: (4) x64 Intel(R) Core(TM) i7-6600U CPU @ 2.60GHz
  Binaries:
    Node: 14.15.0 - C:\Program Files\Node.js\node.EXE
    Yarn: 1.22.5 - C:\Program Files (x86)\Yarn\bin\yarn.CMD
    npm: 6.14.8 - C:\Program Files\Node.js\npm.CMD
  Browsers:
    Chrome: 86.0.4240.183
    Edge: Spartan (44.19041.423.0), Chromium (86.0.622.63)
  npmPackages:
    @storybook/addon-actions: 6.1.0-beta.2 => 6.1.0-beta.2
    @storybook/addon-knobs: 6.1.0-beta.2 => 6.1.0-beta.2
    @storybook/addons: 6.1.0-beta.2 => 6.1.0-beta.2
    @storybook/core: 6.1.0-beta.2 => 6.1.0-beta.2
    @storybook/react: 6.1.0-beta.2 => 6.1.0-beta.2
    @storybook/theming: 6.1.0-beta.2 => 6.1.0-beta.2

Additional context The file exists, so I don’t know why the warning is appearing:

$ file node_modules/simple-statistics/package.json
node_modules/simple-statistics/package.json: JSON data

$ cat node_modules/simple-statistics/package.json
{
  "name": "simple-statistics",
  "version": "7.3.2",
  "description": "Simple Statistics",
  "author": "Tom MacWright <tom@macwright.org> (http://macwright.org/)",
  "repository": {
    "type": "git",
    "url": "git://github.com/simple-statistics/simple-statistics.git"
  },
  "files": [
    "src",
    "dist",
    "index.js",
    "index.d.ts"
  ],
  "devDependencies": {
    "@rollup/plugin-buble": "^0.21.1",
    "cz-conventional-changelog": "^3.0.2",
    "documentation": "^13",
    "eslint": "^7.2.0",
    "eslint-plugin-prettier": "^3.0.0",
    "prettier": "^2.0.2",
    "random-js": "^2.0.0",
    "rollup": "^2.3.2",
    "rollup-plugin-terser": "^7.0.1",
    "standard-version": "^9.0.0",
    "tap": "^14.4.1",
    "typescript": "^4.0.2"
  },
  "scripts": {
    "release": "standard-version && sh ./scripts/update_website.sh",
    "test": "rollup -c rollup.config.js && npm run lint && tap --coverage test/*.test.js --jobs=4",
    "build": "rollup -c rollup.config.js",
    "prepublish": "rollup -c rollup.config.js && ./scripts/update_readme.js",
    "prelint": "tsc --skipLibCheck",
    "lint": "eslint index.js src test && prettier --check src/*.d.ts",
    "postlint": "documentation lint src"
  },
  "source": "index.js",
  "main": "dist/simple-statistics.js",
  "module": "dist/simple-statistics.mjs",
  "umd:main": "dist/simple-statistics.min.js",
  "browser": "dist/simple-statistics.min.js",
  "unpkg": "dist/simple-statistics.min.js",
  "types": "index.d.ts",
  "exports": {
    "import": "./dist/simple-statistics.mjs",
    "require": "./dist/simple-statistics.js"
  },
  "engines": {
    "node": "*"
  },
  "license": "ISC",
  "keywords": [
    "descriptive",
    "linear",
    "math",
    "probability",
    "regression",
    "statistics"
  ],
  "config": {
    "commitizen": {
      "path": "./node_modules/cz-conventional-changelog"
    }
  }
}

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 13
  • Comments: 15 (5 by maintainers)

Most upvoted comments

Tried to migrate nx storybook

info  @storybook/addon-docs         ^6.5.9  →           ^7.0.0-alpha.16
info  @storybook/addon-storysource  ^6.5.9  →           ^7.0.0-alpha.16
info  storybook-dark-mode           ^1.1.0  →  ^1.1.1-canary.120.3965.0
info  @nrwl/storybook               14.4.3  →             14.5.0-beta.4
info  @storybook/addon-essentials   ~6.5.9  →           ~7.0.0-alpha.16
info  @storybook/builder-webpack5   ~6.5.9  →           ~7.0.0-alpha.16
info  @storybook/core-server        ~6.5.9  →           ~7.0.0-alpha.16
info  @storybook/manager-webpack5   ~6.5.9  →           ~7.0.0-alpha.10
info  @storybook/react              ~6.5.9  →           ~7.0.0-alpha.16
info  storybook-addon-designs       ^6.3.1  →            ^7.0.0-alpha.2

looks like migration went well, but when I’m trying to run storybook - got an error:

Package subpath './dist/cjs/server/options' is not defined by "exports" in /Users/username/project/project-mono/node_modules/@storybook/react/package.json

Crikey!! I just released https://github.com/storybookjs/storybook/releases/tag/v6.3.0-alpha.19 containing PR #14785 that references this issue. Upgrade today to the @next NPM tag to try it out!

npx sb upgrade --prerelease

Closing this issue. Please re-open if you think there’s still more to do.

Dug into this a little bit out of curiosity and found that it seems to be triggered by deps/devDeps that include an exports configuration in their package.json that does not explicitly export the package.json file itself. Rollup’s config, as an example:

  "exports": {
    ".": {
      "node": {
        "require": "./dist/rollup.js",
        "import": "./dist/es/rollup.js"
      },
      "default": "./dist/es/rollup.browser.js"
    },
    "./dist/": "./dist/"
  }

And the error it generates (which is not currently displayed anywhere – this catch expression swallows the error text):

Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './package.json' is not defined by "exports" in /path/to/node_modules/rollup/package.json

I’m not familiar enough with the config to say whether this is a misconfiguration on Rollup’s end or a correct configuration and thus a failure on the Storybook end to handle this particular case.

Having a similar issue to @Klypalskyi (only difference is that mine is failing at manager-preset.js)

Framework info:

"next": "^12.2.5",
"next-plugin-preact": "^3.0.7",
"preact": "^10.10.6",
"preact-render-to-string": "^5.2.2",
"react": "npm:@preact/compat@^17.1.1",
"react-dom": "npm:@preact/compat@^17.1.1",
"react-ssr-prepass": "npm:preact-ssr-prepass@^1.2.0",

Stacktrace

C:\Users\$user\Documents\$project>npm run storybook

> $project@0.1.0 storybook
> start-storybook -p 6006     

info @storybook/react v6.5.10
info
info => Loading presets
WARN   Failed to load preset: "C:\\Users\\$user\\Documents\\$project\\node_modules\\@storybook\\manager-webpack5\\dist\\cjs\\presets\\manager-preset.js"
ERR! Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './package.json' is not defined by "exports" in C:\Users\$user\Documents\$project\node_modules\react\package.json
ERR!     at new NodeError (node:internal/errors:371:5)
ERR!     at throwExportsNotFound (node:internal/modules/esm/resolve:453:9)
ERR!     at packageExportsResolve (node:internal/modules/esm/resolve:731:3)
ERR!     at resolveExports (node:internal/modules/cjs/loader:482:36)
ERR!     at Function.Module._findPath (node:internal/modules/cjs/loader:522:31)
ERR!     at Function.Module._resolveFilename (node:internal/modules/cjs/loader:919:27)
ERR!     at resolveFileName (C:\Users\$user\Documents\$project\node_modules\@storybook\ui\node_modules\resolve-from\index.js:29:39)
ERR!     at resolveFrom (C:\Users\$user\Documents\$project\node_modules\@storybook\ui\node_modules\resolve-from\index.js:43:9)
ERR!     at module.exports (C:\Users\$user\Documents\$project\node_modules\@storybook\ui\node_modules\resolve-from\index.js:46:47)
ERR!     at Object.<anonymous> (C:\Users\$user\Documents\$project\node_modules\@storybook\ui\paths.js:17:18)
ERR!  Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './package.json' is not defined by "exports" in C:\Users\$user\Documents\$project\node_modules\react\package.json
ERR!     at new NodeError (node:internal/errors:371:5)
ERR!     at throwExportsNotFound (node:internal/modules/esm/resolve:453:9)
ERR!     at packageExportsResolve (node:internal/modules/esm/resolve:731:3)
ERR!     at resolveExports (node:internal/modules/cjs/loader:482:36)
ERR!     at Function.Module._findPath (node:internal/modules/cjs/loader:522:31)
ERR!     at Function.Module._resolveFilename (node:internal/modules/cjs/loader:919:27)
ERR!     at resolveFileName (C:\Users\$user\Documents\$project\node_modules\@storybook\ui\node_modules\resolve-from\index.js:29:39)
ERR!     at resolveFrom (C:\Users\$user\Documents\$project\node_modules\@storybook\ui\node_modules\resolve-from\index.js:43:9)
ERR!     at module.exports (C:\Users\$user\Documents\$project\node_modules\@storybook\ui\node_modules\resolve-from\index.js:46:47)
ERR!     at Object.<anonymous> (C:\Users\$user\Documents\$project\node_modules\@storybook\ui\paths.js:17:18) {
ERR!   code: 'ERR_PACKAGE_PATH_NOT_EXPORTED'
ERR! }
ERR! Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './package.json' is not defined by "exports" in C:\Users\$user\Documents\$project\node_modules\react\package.json
ERR!     at new NodeError (node:internal/errors:371:5)
ERR!     at throwExportsNotFound (node:internal/modules/esm/resolve:453:9)
ERR!     at packageExportsResolve (node:internal/modules/esm/resolve:731:3)
ERR!     at resolveExports (node:internal/modules/cjs/loader:482:36)
ERR!     at Function.Module._findPath (node:internal/modules/cjs/loader:522:31)
ERR!     at Function.Module._resolveFilename (node:internal/modules/cjs/loader:919:27)
ERR!     at Function.resolve (node:internal/modules/cjs/helpers:108:19)
ERR!     at _default (C:\Users\$user\Documents\$project\node_modules\@storybook\builder-webpack5\dist\cjs\preview\iframe-webpack.config.js:202:46)
ERR!     at async starterGeneratorFn (C:\Users\$user\Documents\$project\node_modules\@storybook\builder-webpack5\dist\cjs\index.js:116:16)
ERR!     at async Object.start (C:\Users\$user\Documents\$project\node_modules\@storybook\builder-webpack5\dist\cjs\index.js:272:14)
ERR!  Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './package.json' is not defined by "exports" in C:\Users\$user\Documents\$project\node_modules\react\package.json
ERR!     at new NodeError (node:internal/errors:371:5)
ERR!     at throwExportsNotFound (node:internal/modules/esm/resolve:453:9)
ERR!     at packageExportsResolve (node:internal/modules/esm/resolve:731:3)
ERR!     at resolveExports (node:internal/modules/cjs/loader:482:36)
ERR!     at Function.Module._findPath (node:internal/modules/cjs/loader:522:31)
ERR!     at Function.Module._resolveFilename (node:internal/modules/cjs/loader:919:27)
ERR!     at Function.resolve (node:internal/modules/cjs/helpers:108:19)
ERR!     at _default (C:\Users\$user\Documents\$project\node_modules\@storybook\builder-webpack5\dist\cjs\preview\iframe-webpack.config.js:202:46)
ERR!     at async starterGeneratorFn (C:\Users\$user\Documents\$project\node_modules\@storybook\builder-webpack5\dist\cjs\index.js:116:16)
ERR!     at async Object.start (C:\Users\$user\Documents\$project\node_modules\@storybook\builder-webpack5\dist\cjs\index.js:272:14) {
ERR!   code: 'ERR_PACKAGE_PATH_NOT_EXPORTED'
ERR! }

WARN Broken build, fix the error above.
WARN You may need to refresh the browser.

info => Loading presets
√ Would you like to send crash reports to Storybook? ... yes

Same for me as for @clover-omelnyk @shilman Can you please take a look?

I’m trying to use it with: "next": "12.2.2", "preact": "10.7.3", "preact-render-to-string": "5.2.0", "react": "npm:@preact/compat@^17.1.1", "react-dom": "npm:@preact/compat@^17.1.1"

info  @nrwl/storybook              ^14.5.7  →   ^14.6.0-beta.4
info  @storybook/addon-essentials   ~6.5.9  →  ~7.0.0-alpha.23
info  @storybook/builder-webpack5   ~6.5.9  →  ~7.0.0-alpha.23
info  @storybook/core-server        ~6.5.9  →  ~7.0.0-alpha.23
info  @storybook/manager-webpack5   ~6.5.9  →  ~7.0.0-alpha.10
info  @storybook/react              ~6.5.9  →  ~7.0.0-alpha.23

image

P.s. 6.5.9 is throwing an error about:

Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './package.json' is not defined by "exports" in /Users/klypalskyi/Documents/Techery/SunRider/sunrider/node_modules/react/package.json