skip to Main Content

When I typed npm start following error is given ;

npm ERR! Linux 4.4.0-109-generic
npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "start"
npm ERR! node v4.2.6
npm ERR! npm  v3.5.2

npm ERR! missing script: start
npm ERR!
npm ERR! If you need help, you may report this error at:
npm ERR!     <https://github.com/npm/npm/issues>

Following package.json works in the another server. I tried to deploy my nodejs app to another server.I succesfully installed the nodejs and npm.

Note: After installing npm there is no node_modules folder under the my project folder.

My package.json file is like;

{
  "name": "myapplication",
  "version": "1.0.0",
  "description": "myapplication",
  "main": "index.js",
  "scripts": {
    "test": "mocha",
    "dev": "pm2 start ecosystem.config.js",
    "pro": "pm2 start ecosystem.config.js --env production"
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "apn": "2.1.5",
    "async": "2.5.0",
    "body-parser": "1.17.2",
    "bootstrap": "3.3.7",
    "callback2promise": "1.0.3",
    "cookie-parser": "1.4.3",
    "express": "4.15.4",
    "express-session": "1.15.5",
    "geolib": "2.0.23",
    "image-type": "3.0.0",
    "jsonwebtoken": "7.4.3",
    "jimp": "0.2.28",
    "mkdirp": "0.5.1",
    "mongoose": "4.11.9",
    "morgan": "1.8.2",
    "multer": "1.3.0",
    "node-gcm": "0.14.6",
    "nodemailer": "4.1.0",
    "shortid": "2.2.8",
    "socket.io": "2.0.3",
    "socket.io-redis": "5.2.0",
    "twitter": "1.7.1",
    "underscore-node": "0.1.2",
    "bcrypt": "1.0.3" 
  },
  "devDependencies": {
    "eslint": "4.5.0"
  }
}

4

Answers


  1. Add a start script in the package.json file

    {
      "version": "1.0.0",
      "description": "No description",
      "main": "index.js",
      "scripts": {
        ...
        "start": "node index.js"
        ...
      },
      "license": "Unlicense",
      "private": true,
      "dependencies": {
      },
      "devDependencies": {
      }
    }
    
    Login or Signup to reply.
  2. To download and install all modules in the node_modules/ folder, you need to use install and not start. As start is not predefined by npm, you need to define a custom script for it, if you want to use the comment.

    So install is the default command to download and install all modules, depending on you package.json:

    $ npm install
    
    Login or Signup to reply.
  3. Change “test” into “start” in scripts dictionary as:

      {
        "name": "myapplication",
        "version": "1.0.0",
        "description": "myapplication",
        "main": "index.js",
        "scripts": {
        "**start**": "mocha",
        "dev": "pm2 start ecosystem.config.js",
        "pro": "pm2 start ecosystem.config.js --env production"
      },
      "author": "",
      "license": "ISC",
      "dependencies": 
      {
        "apn": "2.1.5",
        "async": "2.5.0",
        "body-parser": "1.17.2",
        "bootstrap": "3.3.7",
        "callback2promise": "1.0.3",
        "cookie-parser": "1.4.3",
        "express": "4.15.4",
        "express-session": "1.15.5",
        "geolib": "2.0.23",
        "image-type": "3.0.0",
        "jsonwebtoken": "7.4.3",
        "jimp": "0.2.28",
        "mkdirp": "0.5.1",
        "mongoose": "4.11.9",
        "morgan": "1.8.2",
        "multer": "1.3.0",
        "node-gcm": "0.14.6",
        "nodemailer": "4.1.0",
        "shortid": "2.2.8",
        "socket.io": "2.0.3",
        "socket.io-redis": "5.2.0",
        "twitter": "1.7.1",
        "underscore-node": "0.1.2",
        "bcrypt": "1.0.3" 
      },
      "devDependencies": 
      {
        "eslint": "4.5.0"
      }
    }
    

    This is the appropriate solution that has worked for me. I used

    "scripts": 
    {
         .
         .
    
        "**start**": "webpack-dev-server --open",
    
         .
         .
    }
    

    As I am using ‘webpack’ as a loader.

    Login or Signup to reply.
  4. Just re-install the create-react-app package globally on your system using below command and it should work.

    npm install -g create-react-app
    

    then create react app using below command

    create-react-app <your app name>
    

    then go to your app directory and run the “npm start” command.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search