Getting below error while "npm run build" on server.On local machine working fine. Getting 500 response on server
node version:8.0
npm version: 5.0.3
Error: Cannot find module 'has-flag'
at Function.Module._resolveFilename (module.js:485:15)
at Function.Module._load (module.js:437:25)
at Module.require (module.js:513:17)
at require (internal/module.js:11:18)
at Object.<anonymous>
(/usr/share/../../../node_modules/postcss/node_modules/supports-color/index.js:2:15)
at Module._compile (module.js:569:30)
at Object.Module._extensions..js (module.js:580:10)
at Module.load (module.js:503:32)
at tryModuleLoad (module.js:466:12)
at Function.Module._load (module.js:458:3)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! ***@0.1.0 build: `react-scripts build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the ***@0.1.0 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
If you are getting the "Cannot find module" error when trying to run a local file, make sure that the path you passed to the node command points to a file that exists. For example, if you run node src/index. js , make sure that the path src/index. js points to an existing file.
A module not found error can occur for many different reasons: The module you're trying to import is not installed in your dependencies. The module you're trying to import is in a different directory. The module you're trying to import has a different casing.
npm install -s. The -s flag is a shorthand for the silent configuration, which sets the log level of your npm installation process to nothing. The following Terminal commands are all equal: npm install -s npm install --silent npm install --loglevel silent.
To fix Cannot find module errors, install the modules properly by running a npm install command in the appropriate directory as your project's app. js or index. js file. or delete the node_modules folder and package-lock.
Try npm install --save has-flag
. It looks like supports-color
is requiring has-flag
to be installed but it isn't. If you need to install any other packages you can just type npm install
.
The above didn't work for me, but deleting my node_modules and dist folders and rerunning npm install did.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With