3

I have the following files in my NPM package:

package.json:

{
  "name": "npm-start",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC"
}

index.js

console.log('Hello world!');

When I try to run npm start, I get an error message:

> npm start
npm ERR! missing script: start

Okay, it's true: I don't have a "start" property in "scripts" object. But NPM's CLI Documentation claims this about npm start:

If no "start" property is specified on the "scripts" object, it will run node server.js.

Why is NPM failing me? Isn't it supposed to invoke node in this scenario? Am I missing something? (Of course, manually invoking node works fine).

In case it's relevant:

> npm -version
5.3.0

2 Answers 2

1

As soon as I finished typing the question, I realized my error.

When "start" property is absent, NPM will invoke node with server.js. But I don't have a server.js. NPM checks under the hood for this server.js file, and fails if it's not present. Ideally though, NPM should have reported that server.js wasn't found. The current way of handling things is confusing.

As soon as you have a server.js file, npm start works fine.

Sign up to request clarification or add additional context in comments.

Comments

0

I had this issue as well. I re-installed my npm@4 and my [email protected]. Then created my project again using the commands

create-react-native-app AwesomeProject
sudo npm start (mac command)

It worked for me!

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.