Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Local package.json exists, but node_modules missing

I am trying to start a Redux application I just cloned from a GitHub repository.

I tried to run it with the following command

npm start 

I am getting this error

> [email protected] start /home/workspace/assignment > webpack-dev-server --config ./configs/webpack/webpack.config.development.js  sh: 1: webpack-dev-server: not found npm ERR! file sh npm ERR! code ELIFECYCLE npm ERR! errno ENOENT npm ERR! syscall spawn npm ERR! [email protected] start: `webpack-dev-server --config ./configs/webpack/webpack.config.development.js` npm ERR! spawn ENOENT npm ERR!  npm ERR! Failed at the [email protected] start script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above. npm WARN Local package.json exists, but node_modules missing, did you mean to install?  npm ERR! A complete log of this run can be found in: npm ERR!     /home/.npm/_logs/2018-05-15T16_32_44_571Z-debug.log 

Any help will be appreciated

like image 865
Deepak Mahakale Avatar asked May 15 '18 16:05

Deepak Mahakale


People also ask

Where are my node_modules?

Global modules are installed in the /usr/local/lib/node_modules project directory in the standard system, which is the system's root.

Does npm install create node_modules folder?

npm install does not create node_modules folder and not downloading any dependencies.

Should I include node_modules in git?

You should not include folder node_modules in your . gitignore file (or rather you should include folder node_modules in your source deployed to Heroku). If folder node_modules: exists then npm install will use those vendored libraries and will rebuild any binary dependencies with npm rebuild .

Is node_modules necessary after build?

No, You don't need to push your node_modules folder to production whether it is a static export or dynamic build. When you export a static build the source file is converted into HTML & js files. So there is no need for node modules on production env.


2 Answers

npm start runs a script that the app maker built for easy starting of the app npm install installs all the packages in package.json

run npm install first

then run npm start

like image 157
Dan Avatar answered Oct 05 '22 03:10

Dan


Just had the same error message, but when I was running a package.json with:

"scripts": {     "build": "tsc -p ./src", } 

tsc is the command to run the TypeScript compiler.

I never had any issues with this project because I had TypeScript installed as a global module. As this project didn't include TypeScript as a dev dependency (and expected it to be installed as global), I had the error when testing in another machine (without TypeScript) and running npm install didn't fix the problem. So I had to include TypeScript as a dev dependency (npm install typescript --save-dev) to solve the problem.

like image 29
Zanon Avatar answered Oct 05 '22 05:10

Zanon