Closed kaiyoma closed 3 years ago
This seems to be due to the package composition implementation:
https://github.com/storybookjs/storybook/blob/next/lib/core/src/server/manager/manager-config.ts#L34
@ndelangen can you help?
Hi everyone! Seems like there hasn't been much going on in this issue lately. If there are still questions, comments, or bugs, please feel free to continue the discussion. Unfortunately, we don't have time to get to every issue. We are always open to contributions so please send us a pull request if you would like to help. Inactive issues will be closed after 30 days. Thanks!
Pretty sure this is still an issue.
I'm seeing this on rollup packages specifically:
WARN unable to find package.json for @rollup/plugin-node-resolve
WARN unable to find package.json for rollup
WARN unable to find package.json for rollup-plugin-terser
Here is node_modules/rollup/package.json
{
"name": "rollup",
"version": "2.41.5",
"description": "Next-generation ES module bundler",
"main": "dist/rollup.js",
"module": "dist/es/rollup.js",
"typings": "dist/rollup.d.ts",
"bin": {
"rollup": "dist/bin/rollup"
},
"scripts": {
"build": "shx rm -rf dist && git rev-parse HEAD > .commithash && rollup -c && shx cp src/rollup/types.d.ts dist/rollup.d.ts && shx chmod a+x dist/bin/rollup",
"build:cjs": "shx rm -rf dist && rollup -c --configTest && shx cp src/rollup/types.d.ts dist/rollup.d.ts && shx chmod a+x dist/bin/rollup",
"build:bootstrap": "dist/bin/rollup -c && shx cp src/rollup/types.d.ts dist/rollup.d.ts && shx chmod a+x dist/bin/rollup",
"ci:lint": "npm run lint:nofix",
"ci:test": "npm run build:cjs && npm run build:bootstrap && npm run test:all",
"ci:test:only": "npm run build:cjs && npm run build:bootstrap && npm run test:only",
"ci:coverage": "npm run build:cjs && nyc --reporter lcovonly mocha && codecov",
"lint": "npm run lint:ts -- --fix && npm run lint:js -- --fix && npm run lint:markdown",
"lint:nofix": "npm run lint:ts && npm run lint:js && npm run lint:markdown",
"lint:ts": "tslint --project .",
"lint:js": "eslint test/test.js test/*/index.js test/utils.js test/**/_config.js",
"lint:markdown": "markdownlint --config markdownlint.json docs/**/*.md",
"perf": "npm run build:cjs && node --expose-gc scripts/perf.js",
"perf:debug": "node --inspect-brk scripts/perf-debug.js",
"perf:init": "node scripts/perf-init.js",
"_postinstall": "husky install",
"postpublish": "pinst --enable && git push && git push --tags",
"prepare": "npm run build",
"prepublishOnly": "pinst --disable && npm ci && npm run lint:nofix && npm run security && npm run build:bootstrap && npm run test:all",
"security": "npm audit",
"test": "npm run build && npm run test:all",
"test:cjs": "npm run build:cjs && npm run test:only",
"test:quick": "mocha -b test/test.js",
"test:all": "npm run test:only && npm run test:browser && npm run test:typescript && npm run test:leak && npm run test:package",
"test:coverage": "npm run build:cjs && shx rm -rf coverage/* && nyc --reporter html mocha test/test.js",
"test:coverage:browser": "npm run build && shx rm -rf coverage/* && nyc mocha test/browser/index.js",
"test:leak": "node --expose-gc test/leak/index.js",
"test:package": "node scripts/test-package.js",
"test:only": "mocha test/test.js",
"test:typescript": "shx rm -rf test/typescript/dist && shx cp -r dist test/typescript/ && tsc --noEmit -p test/typescript && tsc --noEmit",
"test:browser": "mocha test/browser/index.js",
"watch": "rollup -cw"
},
"repository": "rollup/rollup",
"keywords": [
"modules",
"bundler",
"bundling",
"es6",
"optimizer"
],
"author": "Rich Harris",
"license": "MIT",
"bugs": {
"url": "https://github.com/rollup/rollup/issues"
},
"homepage": "https://rollupjs.org/",
"optionalDependencies": {
"fsevents": "~2.3.1"
},
"devDependencies": {
"@rollup/plugin-alias": "^3.1.2",
"@rollup/plugin-buble": "^0.21.3",
"@rollup/plugin-commonjs": "^18.0.0-1",
"@rollup/plugin-json": "^4.1.0",
"@rollup/plugin-node-resolve": "^11.1.1",
"@rollup/plugin-replace": "^2.3.4",
"@types/micromatch": "^4.0.1",
"@types/node": "^10.17.51",
"@types/require-relative": "^0.8.0",
"@types/signal-exit": "^3.0.0",
"@types/yargs-parser": "^20.2.0",
"acorn": "^8.0.5",
"acorn-class-fields": "^1.0.0",
"acorn-jsx": "^5.3.1",
"acorn-static-class-features": "^1.0.0",
"acorn-walk": "^8.0.2",
"buble": "^0.20.0",
"chokidar": "^3.5.1",
"codecov": "^3.8.1",
"colorette": "^1.2.1",
"core-js": "^3.8.3",
"date-time": "^3.1.0",
"es5-shim": "^4.5.15",
"es6-shim": "^0.35.6",
"eslint": "^7.19.0",
"eslint-plugin-import": "^2.22.1",
"execa": "^5.0.0",
"fixturify": "^2.1.0",
"hash.js": "^1.1.7",
"husky": "^5.0.9",
"is-reference": "lukastaegert/is-reference#update-class-features",
"lint-staged": "^10.5.4",
"locate-character": "^2.0.5",
"magic-string": "^0.25.7",
"markdownlint-cli": "^0.26.0",
"micromatch": "^4.0.2",
"mocha": "^8.3.0",
"node-fetch": "^2.6.1",
"nyc": "^15.1.0",
"pinst": "^2.1.4",
"prettier": "^2.2.1",
"pretty-bytes": "^5.5.0",
"pretty-ms": "^7.0.1",
"require-relative": "^0.8.7",
"requirejs": "^2.3.6",
"rollup": "^2.38.5",
"rollup-plugin-license": "^2.2.0",
"rollup-plugin-string": "^3.0.0",
"rollup-plugin-terser": "^7.0.2",
"rollup-plugin-thatworks": "^1.0.4",
"rollup-plugin-typescript": "^1.0.1",
"rollup-pluginutils": "^2.8.2",
"sander": "^0.6.0",
"shx": "^0.3.3",
"signal-exit": "^3.0.3",
"source-map": "^0.7.3",
"source-map-support": "^0.5.19",
"sourcemap-codec": "^1.4.8",
"systemjs": "^6.8.3",
"terser": "^5.6.0-beta",
"tslib": "^2.1.0",
"tslint": "^6.1.3",
"typescript": "^4.1.5",
"url-parse": "^1.4.7",
"weak-napi": "^2.0.2",
"yargs-parser": "^20.2.4"
},
"files": [
"dist/**/*.js",
"dist/*.d.ts",
"dist/bin/rollup",
"dist/rollup.browser.js.map"
],
"engines": {
"node": ">=10.0.0"
},
"exports": {
".": {
"node": {
"require": "./dist/rollup.js",
"import": "./dist/es/rollup.js"
},
"default": "./dist/es/rollup.browser.js"
},
"./dist/": "./dist/"
}
}
If you want this fixed, please upvote by adding a 👍 to the issue description. We use this to help prioritize!
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.
dupe to #14000
For what it's worth, I'm seeing this with date-and-time. Here's the exception that triggers the message:
Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './package.json' is not defined by "exports" in /Users/jon/Developer/web/webpack/node_modules/date-and-time/package.json
at new NodeError (node:internal/errors:329:5)
at throwExportsNotFound (node:internal/modules/esm/resolve:337:9)
at packageExportsResolve (node:internal/modules/esm/resolve:562:3)
at resolveExports (node:internal/modules/cjs/loader:473:36)
at Function.Module._findPath (node:internal/modules/cjs/loader:513:31)
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:910:27)
at resolveFileName (/Users/jon/Developer/web/webpack/node_modules/resolve-from/index.js:29:39)
at resolveFrom (/Users/jon/Developer/web/webpack/node_modules/resolve-from/index.js:43:9)
at module.exports (/Users/jon/Developer/web/webpack/node_modules/resolve-from/index.js:46:47)
at /Users/jon/Developer/web/webpack/node_modules/@storybook/core-server/dist/cjs/manager/manager-config.js:51:40
at Array.map (<anonymous>)
at getAutoRefs (/Users/jon/Developer/web/webpack/node_modules/@storybook/core-server/dist/cjs/manager/manager-config.js:49:37)
at async getPrebuiltDir (/Users/jon/Developer/web/webpack/node_modules/@storybook/core-server/dist/cjs/utils/prebuilt-manager.js:60:18)
at async Object.start (/Users/jon/Developer/web/webpack/node_modules/@storybook/core-server/dist/cjs/manager/builder.js:93:21)
at async Promise.all (index 1)
at async storybookDevServer (/Users/jon/Developer/web/webpack/node_modules/@storybook/core-server/dist/cjs/dev-server.js:103:28)
and date-and-time's package.json:
{
"name": "date-and-time",
"version": "1.0.0",
"description": "A Minimalist DateTime utility for Node.js and the browser",
"main": "date-and-time.js",
"module": "esm/date-and-time.es.js",
"unpkg": "date-and-time.min.js",
"exports": {
".": {
"browser": "./esm/date-and-time.es.js",
"import": "./esm/date-and-time.mjs",
"require": "./date-and-time.js"
},
"./locale/*": {
"browser": "./esm/locale/*.es.js",
"import": "./esm/locale/*.mjs",
"require": "./locale/*.js"
},
"./plugin/*": {
"browser": "./esm/plugin/*.es.js",
"import": "./esm/plugin/*.mjs",
"require": "./plugin/*.js"
}
},
"scripts": {
"build": "rollup --config rollup.config.js",
"test": "./test.sh"
},
"repository": {
"type": "git",
"url": "https://github.com/knowledgecode/date-and-time.git"
},
"keywords": [
"date",
"time",
"format",
"parse",
"utility"
],
"author": "KNOWLEDGECODE",
"license": "MIT",
"bugs": {
"url": "https://github.com/knowledgecode/date-and-time/issues"
},
"homepage": "https://github.com/knowledgecode/date-and-time",
"devDependencies": {
"@ampproject/rollup-plugin-closure-compiler": "^0.26.0",
"expect.js": "^0.3.1",
"mocha": "^8.3.2",
"mocha-headless-chrome": "^3.1.0",
"rollup": "^2.44.0"
}
}
I'm seeing this as well for framer-motion. They also seem to use rollup to build.
Since this error seems to pop up for a lot of packages when building storybook, it would be nice to have a way to address it from storybook's end. Storybook's build output is already quite verbose, so it would be good to filter out these warnings (unless they're absolutely crucial, but everything still works so they don't seem to be).
I propose we simply drop this warning: https://github.com/storybookjs/storybook/blob/32c63568d6f7f6ef90afd206405524543d5a7068/lib/core-server/src/manager/manager-config.ts#L37
Nothing will break if we do.
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.
Thanks, @shilman. It worked <3
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
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
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
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
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:
Expected behavior No warnings.
Screenshots
System
Additional context The file exists, so I don't know why the warning is appearing: