-
-
Notifications
You must be signed in to change notification settings - Fork 26.9k
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
Respect NODE_PATH environment variable #253
Comments
Do you mean that you read |
Yes, from my current understanding I think it would be sufficient to make Webpack aware of any paths set in Currently I am using a custom setup using browserify, so I was interested in checking this approach. (But since I have not yet "ejected" I didn't fiddle with the Webpack config yet.) |
We do this in resolve: {
modulesDirectories: ['app', 'components', 'node_modules']
} Ref: https://webpack.github.io/docs/configuration.html#resolve-modulesdirectories |
Depending on how we handle testing it might not be sufficient to make Webpack know about it - e.g. if Jest is using a non-webpack build process we would have to make sure Jest can handle NODE_PATH too. cc @cpojer |
True, but I don't fully understand why we wouldn't use our standard build system for our testing setup though. That sounds really fragile and prone to breakage if we change anything… (disclaimer: I haven't read that discussion) |
It sounds sort of fragile but it also helps make sure we don’t deviate way too much into webpackisms. |
Are there any precedents of major tools using |
By default |
(@lacker: Jest does handle NODE_PATH just fine. It also has a |
OK, sounds reasonable. I’d be happy to review a PR adding this. |
|
You do not have use alias for thing you do. modulesDirectories should work. facebook#1136 facebook#276 facebook#253 The change breaks tooling and you should not use it until issues are resolved with it.
Does this solution work for Windows? I tried adding NODE_PATH to 'start' command as suggested, but in windows you can not set path like this I believe. |
You can set |
Above is the code from "webpack.config.dev.js", in which I am trying to configure webpack for my project, Using Node versioned under 8.0.0 it works fine, but Now upgrading Node to 8.0.0+ it crashes saying:
Kindly help me with this. |
I wanted to try out
create-react-app
on our internal monorepo, which is basically structured into 2 folders: "apps" and "components".The "apps" contain just an entry index.js file and their build/transpile configuration and import a root component from the components directory.
This is currently solved by directing imports using
NODE_PATH
environment variable to make tools look into the components folder (so that you can writeimport Button from 'ns-button'
instead ofimport Button from '../../../components/ns-button
).Personally I would feel that this would be worthwhile to support so this project could work with a wide variety of "non-standard" project layouts.
The text was updated successfully, but these errors were encountered: