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

Closed
opened 2020-06-20 16:28:56 +02:00 by zwz · 3 comments
zwz commented 2020-06-20 16:28:56 +02:00 (Migrated from github.com)

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
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 commented 2020-06-22 09:15:09 +02:00 (Migrated from github.com)

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.

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 commented 2020-06-23 15:31:56 +02:00 (Migrated from github.com)

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: []
}
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 commented 2020-06-23 15:46:15 +02:00 (Migrated from github.com)

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

This seems to be an issue with rollup-plugin-svelte (see [this pr](https://github.com/sveltejs/rollup-plugin-svelte/pull/108), for example). I'm going to close this here.
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
marijn/w3c-keyname#10
No description provided.