package.json is not defined by "exports"
See original GitHub issueDescribe the bug
‘./package.json’ is not defined by “exports” when upgrading from v7.0.3 to v8.0.0
To Reproduce
Steps to reproduce the behavior:
- upgrading from v7.0.3 to v8.0.0 and running npm build in a Svelte project
- See error
Expected behavior
A rollup bundle without an error as shown below.
Runtime
- OS: macOS
- Runtime: Node.js
- Runtime Version: 14.1.0
Additional context
This is the command line output after upgrading from v7.0.3 to v8.0.0 in a Svelte project
> Package subpath './package.json' is not defined by "exports" in /Users/sa/0/edm/node_modules/uuid/package.json
Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './package.json' is not defined by "exports" in /Users/sa/0/edm/node_modules/uuid/package.json
at applyExports (internal/modules/cjs/loader.js:491:9)
at resolveExports (internal/modules/cjs/loader.js:507:23)
at Function.Module._findPath (internal/modules/cjs/loader.js:635:31)
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:1007:27)
at Function.requireRelative.resolve (/Users/sa/0/edm/node_modules/require-relative/index.js:30:17)
at tryResolve (/Users/sa/0/edm/node_modules/rollup-plugin-svelte/index.js:50:19)
at Object.resolveId (/Users/sa/0/edm/node_modules/rollup-plugin-svelte/index.js:177:21)
at /Users/sa/0/edm/node_modules/rollup/dist/shared/rollup.js:18217:25
I found some additional information in a SO post that might very well be related to the issue I’m seeing https://stackoverflow.com/questions/61621828/getting-strange-error-using-uuid-npm-module-what-am-i-doing-wrong/61730597#61730597
Issue Analytics
- State:
- Created 3 years ago
- Comments:27 (13 by maintainers)
Top Results From Across the Web
49 - Stack Overflow
When the "exports" field is defined, all subpaths of the package are encapsulated and no longer available to importers.
Read more >Support "exports" field of package.json : WEB-40509 - YouTrack
Open index.js . · Try navigating to definition of HelloDependency from the statement where the instance is constructed. · Delete the import statement...
Read more >Package subpath 'v4' is not defined by 'exports' | bobbyhadz
The error '[ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './v4' is not defined by "exports"' occurs because the uuid module removed the option to import from ...
Read more >When I run yarn start , I get this error - Reddit
Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './lib/tokenize' is not defined by "exports" in /root/.../package.json.
Read more >package subpath is not defined by exports in - You.com
Delete the exports field in node_modules/cesium/package.json . Re-launch npm run dev . Open side panel.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I fixed it by running
npm ci
.In general, I think it’s a good idea for packages to explicitly add
"./package.json": "./package.json"
to their"exports"
field.However, unless the ecosystem is consistently willing to do this, tooling will have to determine a different mechanism for accessing package.jsons - something like
findPackageJSONFrom(path.dirname(require.resolve('pkg')))
.