Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Command `npm start` does nothing

Tags:

node.js

npm

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

like image 906
hawkharris Avatar asked Sep 23 '14 14:09

hawkharris


Video Answer


4 Answers

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.

like image 53
Ramy M. Mousa Avatar answered Oct 16 '22 16:10

Ramy M. Mousa


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.

like image 25
hawkharris Avatar answered Oct 16 '22 14:10

hawkharris


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

like image 6
Mohamed Ben HEnda Avatar answered Oct 16 '22 16:10

Mohamed Ben HEnda


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.

like image 5
Hamfri Avatar answered Oct 16 '22 16:10

Hamfri