I get webpack not found error for my React Build.
-
we need to know your netlify site name.
https://d-smart.netlify.app/ -
Build problems? Link or paste the FULL build log & build settings screenshot
I get webpack not found error for my React Build.
we need to know your netlify site name.
https://d-smart.netlify.app/
Build problems? Link or paste the FULL build log & build settings screenshot
Hi, @RedVelocity. It looks like you resolved the issue now. My best guess is that webpack was missing from package.json
and adding the dependency there would resolve the issue.
​Please let us know if there are any questions and also please feel free to share the solution here (if you want to and it might help someone else if you do).
Hey, the issue is not yet resolved. I’ve added workaround in my build script to explicitly install dev dependencies as follows
npm install --only=dev && npm run build
Hey there @RedVelocity!
here is some general guidance contains a ton of useful debugging tips that can likely help you solve your problem also it would likely be helpful to see your package.json.
Hi, @RedVelocity. I found the root cause of the dependency not installing.
You are causing the devDependencies not to be installed because you are manually setting NODE_ENV
to “production” here:
https://app.netlify.com/sites/d-smart/settings/deploys#environment-variables
You told npm
not to install the devDependencies. This was a setting you changed manually.
With this environment variable to “production”, it will always prevent npm
from installing the devDependencies. This is true anywhere npm
is used. It isn’t something specific to Netlify, it is specific to npm
.
We talk about that in our documentation here, quoting:
Dependencies and production
If you set the
NODE_ENV
toproduction
, anydevDependencies
in yourpackage.json
file will not be installed for the build.
This is covered in the npm
documentation here:
https://docs.npmjs.com/using-npm/config.html#production
To summarize, the only reason this happened is because you configured the environment variable NODE_ENV="production"
which will always cause this behavior on any system running npm
. If there are other questions about this, please let us know.
Hi Luke,
Makes sense!
Out of curiosity, I was wondering about a couple of things.
npm run build
, does this mean the dev dependencies are permanently cached?Appreciate your response, thanks!
Hi, @RedVelocity.
The local node_modules
directory tree is cached by the build image but it isn’t considered permanent. It can manually be deleted and there can be other reasons which cause it to be deleted between builds.
It is there to help speed up builds when possible but it cannot be treated as persistent (because it isn’t).
The key takeaway is this:
npm
works and this behavior is 100% controlled by npm
alone. This always how npm
works with a NODE_ENV="production"
environment variable.The behavior you are seeing has nothing to do with Netlify. In fact, we set NODE_ENV="development"
exactly to prevent this behavior. You changed that default by manually setting it to “production” instead.
This tells npm
, “Do not install the devDependencies.”
If you want this dependency installed when NODE_ENV="production"
then move it to dependencies and don’t put it in devDependencies (or don’t set NODE_ENV="production"
) .