问题
I just created a new project folder and ran the following commands:
- npm init
- npm install express
- npm install express-react-views react react-dom
Created index.js with express imported and views for a sample jsx file. When I run on localhost, I get this error:
Error: Package exports for '<path_to_project_folder>/node_modules/@babel/helper-compilation-targets' do not define a '.' subpath
at applyExports (internal/modules/cjs/loader.js:485:15)
at resolveExports (internal/modules/cjs/loader.js:508:12)
at Function.Module._findPath (internal/modules/cjs/loader.js:577:20)
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:879:27)
at Function.Module._load (internal/modules/cjs/loader.js:785:27)
at Module.require (internal/modules/cjs/loader.js:956:19)
at require (internal/modules/cjs/helpers.js:74:18)
at Object.<anonymous> (<path_to_project_folder>/node_modules/@babel/preset-env/lib/debug.js:8:33)
at Module._compile (internal/modules/cjs/loader.js:1063:30)
at Module._compile (<path_to_project_folder>/node_modules/pirates/lib/index.js:99:24)
In Oct 2019, I created an express app using the same steps ran, and found there is no such package (@babel/helper-compilation-targets), and it ran fine.
I'm not sure what is wrong. Can anyone help to advice? Thank you!
回答1:
Had the same issue. Updating the node.js fixed that for me
回答2:
It will be fixed on babel v7.8.4, see https://github.com/babel/babel/pull/11006. Before a new babel release is cut, please upgrade node.js to >=13.2.0, which incorporates the necessary upstream fix.
Note that node.js 12 is not affected unless you have manually toggled on --experimental-modules flag. If that is the case, please also upgrade node.js to >=13.2.0.
来源:https://stackoverflow.com/questions/59706130/error-package-exports-for-path-to-project-folder-node-modules-babel-helper-c