question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

package.json is not defined by "exports"

See original GitHub issue

Describe 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:

  1. upgrading from v7.0.3 to v8.0.0 and running npm build in a Svelte project
  2. 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:closed
  • Created 3 years ago
  • Comments:27 (13 by maintainers)

github_iconTop GitHub Comments

14reactions
alayorcommented, Dec 28, 2020

I fixed it by running npm ci.

8reactions
ljharbcommented, May 18, 2020

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'))).

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found