Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Package subpath './package.json' is not defined by "exports" #10

Closed
zwz opened this issue Jun 20, 2020 · 3 comments
Closed

Package subpath './package.json' is not defined by "exports" #10

zwz opened this issue Jun 20, 2020 · 3 comments

Comments

@zwz
Copy link

zwz commented Jun 20, 2020

I was using this package in https://github.com/sveltejs/sapper-template/tree/rollup
But it reports error:

Package subpath './package.json' is not defined by "exports" 
in <my-project-path>/node_modules/w3c-keyname/package.json
@marijnh
Copy link
Owner

marijnh commented Jun 22, 2020

Do you have a stack trace for the error? I guess someone is directly requiring package.json, which worked fine in a pre-node-14 world, but is likely to cause this error for packages that declare an exports field now. The best way to fix it is probably to adjust that package to just load and parse the file properly.

@zwz
Copy link
Author

zwz commented Jun 23, 2020

What I did is adding at the beginning of the file sapper-template-rollup/src/routes/index.svelte:

<script>
 import * as Key from  "w3c-keyname"   
</script>

And when I run npm run dev, it reports:

✗ server
Package subpath './package.json' is not defined by "exports" in /Users/rbx0999/project/sapper-template-rollup/node_modules/w3c-keyname/package.json
✗ client
Package subpath './package.json' is not defined by "exports" in /Users/rbx0999/project/sapper-template-rollup/node_modules/w3c-keyname/package.json
internal/modules/cjs/loader.js:1032
  throw err;
  ^

Error: Cannot find module 'sapper-template-rollup/__sapper__/dev/server/server.js'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:1029:15)
    at Function.Module._load (internal/modules/cjs/loader.js:898:27)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
    at internal/main/run_main_module.js:17:47 {
  code: 'MODULE_NOT_FOUND',
  requireStack: []
}

@marijnh
Copy link
Owner

marijnh commented Jun 23, 2020

This seems to be an issue with rollup-plugin-svelte (see this pr, for example). I'm going to close this here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants