🐛 The bug
Requiring @nuxtjs/composition-api/package.json causes an error.
🛠️ To reproduce
Steps to reproduce the behavior:
nodejs >= 12.7.0 and @nuxtjs/composition-api@latestnoderequire('@nuxtjs/composition-api/package.json')$ node
Welcome to Node.js v12.18.0.
Type ".help" for more information.
> require('@nuxtjs/composition-api/package.json')
Uncaught:
Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './package.json' is not defined by "exports" in /Users/resessh/src/github.com/resessh/repro-error/node_modules/@nuxtjs/composition-api/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:953:27)
at Function.Module._load (internal/modules/cjs/loader.js:842:27)
at Module.require (internal/modules/cjs/loader.js:1026:19)
at require (internal/modules/cjs/helpers.js:72:18)
at repl:1:1
at Script.runInThisContext (vm.js:120:20)
at REPLServer.defaultEval (repl.js:433:29) {
code: 'ERR_PACKAGE_PATH_NOT_EXPORTED'
}
>
🌈 Expected behaviour
No error
ℹ️ Additional context
https://github.com/nodejs/node/issues/33460 is relevant discussion over this issue. This behavior is very surprising and the workaround is to add package.json to exports.
@resessh Happy to add. Out of curiosity, what's your use-case?
@danielroe I'm sorry for lack of my use-case. This repo reproduce the problem I'm having trouble with.
There seems to be two problems. One is 'requiring package.json fails', and the other is 'no exports fields for nodejs' .
@danielroe I created a PR and it really solves this problem. Could you check it?
https://github.com/nuxt-community/composition-api/pull/296
Let me know if that doesn't solve your issue.
That release solved my problem. Thank you!! ❤️
Most helpful comment
That release solved my problem. Thank you!! ❤️