hawkharris
hawkharris

Reputation: 2650

Command `npm start` does nothing

After entering npm start in the directory of my Node project, I see the spinning pipe symbol to show that npm is loading. However, this graphic is displayed indefinitely and nothing happens. No error messages are provided. How can I fix or at least diagnose this issue?

My package.json is as follows:

{
  "name": "Project_Name",
  "version": "0.0.1",
  "private": true,
  "main": "./bin/www",
  "scripts": {
    "start": "node ./bin/www"
  },
  "dependencies": {
    "express": "~4.2.0",
    "static-favicon": "~1.0.0",
    "morgan": "~1.0.0",
    "cookie-parser": "~1.0.1",
    "body-parser": "~1.0.0",
    "debug": "~0.7.4",
    "jade": "~1.3.0",
    "request": "~2.39.0",
    "oauth-1.0a": "~0.1.1",
    "passport": "~0.2.0",
    "express-session": "~1.7.2",
    "passport-local": "~1.0.0",
    "connect-flash": "~0.1.1"
  }
}

I suspected that missing dependencies could be a problem, but that doesn't seem to be an issue. I ran the npm-install-missing module and got the following results:

enter image description here

Upvotes: 6

Views: 96796

Answers (6)

Hamfri
Hamfri

Reputation: 2209

Run this command from your console npm config set ignore-scripts false or sudo npm config set ignore-scripts false . This applies to linux or mac users.

Upvotes: 5

ashwath hegde
ashwath hegde

Reputation: 656

I had the similar issue i tried all the above methods but did not work then i noticed that there was node_module folder in my project path which was not belonging to this project . it got installed long back by mistake . once i deleted that particular folder then my react project started to work

Upvotes: 0

Ramy M. Mousa
Ramy M. Mousa

Reputation: 5933

After several uninstall and install to node and npm the problem was that I set ignore-scripts=true in .npmrc at ~/ directory

so to solve this:

nano ~/.npmrc

remove the line ignore-scripts=true or change it to be

ignore-scripts=false

This solved my problem after about an hour of trying different extreme solutions.

Upvotes: 14

Neeraj Kumar
Neeraj Kumar

Reputation: 7501

Actually whenever you run npm start,

it runs a package's "start" script, if one was provided. If no version is specified, then it starts the "active" version.

So, npm looks into your package.json file which should be having something like

"start": "webpack-dev-server --hot"

then it will do that. If npm can't find your start script, it defaults to:

node server.js

Upvotes: 2

Mohamed Ben HEnda
Mohamed Ben HEnda

Reputation: 2766

1- You must install connect and server-static modules

npm install connect serve-static

2- You must create server.js file that contains:

var connect = require('connect');
var serveStatic = require('serve-static');
connect().use(serveStatic(__dirname)).listen(8000);

3- Run your command:

node server

4- for testing add a HTML file (index.html) in your nodejs directory

5- Open the browser and put :

http://localhost:8000/index.html

the server is running and your page html is dipalyed

Upvotes: 6

hawkharris
hawkharris

Reputation: 2650

The problem had to do with dependencies. First, I installed the npm-install-missing module to see the app's dependencies:

npm install -g npm-install-missing

With the module installed, I could run it to see which dependencies needed to be updated:

npm-install-missing

The results are shown as a screenshot in my question above. You'll notice that express-session, crypto-js and passport are in red. I needed to install the expected version of each of these modules:

npm install -g [email protected]

npm install -g [email protected]

npm install -g [email protected]

After installing the dependencies, I ran npm start again. The app appeared on localhost:3000.

Upvotes: 8

Related Questions