.env NODE_PATH is not working in v1.0.0
See original GitHub issueDescription
I have NODE_PATH=src
in .env
, it did work great in v0.9.5. After yarn upgrade react-scripts
it doesn’t work now. And I didn’t see any related guide in the v1.0.0 changelog.
(referenced from https://github.com/facebookincubator/create-react-app/issues/2188)
I’ve also tried in a fresh new project and it doesn’t work.
Expected behavior
Should be able to import 'foo/bar'
which foo
is a folder located in src
Actual behavior
Module not found: Can't resolve 'foo/bar' in '/Users/some/path/src'
Environment
Run these commands in the project folder and fill in their results:
npm ls react-scripts
(if you haven’t ejected): v1.0.0node -v
: v7.1.0npm -v
: v3.10.9
Then, specify:
- Operating system: macOS Sierra
- Browser and version: Chrome 58
Reproducible Demo
https://github.com/CodinCat/cra-env-issue
This is a fresh new project. See /src/index.js:5
Issue Analytics
- State:
- Created 6 years ago
- Reactions:6
- Comments:39 (27 by maintainers)
Top Results From Across the Web
ReactJS 'NODE_PATH' is not recognized as an internal or ...
Im running node v17.5.0 using npm 8.4.1 . NB!! All the files below are located in the root of my project. This is...
Read more >Command-line API | Node.js v19.3.0 Documentation
The program entry point is a specifier-like string. If the string is not an absolute path, it's resolved as a relative path from...
Read more >API - ESBuild
This API call is used by the command-line interface if no input files are ... If needed, the working directory that esbuild uses...
Read more >Working with Environment Variables in Node.js - Twilio
Environment variables are a great way to configure parts of your Node.js application. Learn how to work with them using helpful tools such ......
Read more >How to resolve 'node' is not recognized as an internal or ...
Open the Environment Variables option in your Control Panel. · Select the variable named Path. · Restart the command prompt again and now...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Would you consider adding Webpack alias? I really think that
NODE_PATH
is just some kind of escape hatch to get rid of relative paths and might lead to some naming conflict. It would be really more convenient If we can have an alias.I think the idea in Vue webpack template is great: (https://github.com/vuejs-templates/webpack/blob/master/template/build/webpack.base.conf.js)
so you can
and it’s totally optional for users. Anyone who prefer relative paths can simply keep using them and ignore the alias. Of course it doesn’t need to be
@
, this can be discussed.Thanks for the suggestion @RIP21 but still not working for me, I was already running tests like this: