Reputation: 22280
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 runnode 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
Upvotes: 3
Views: 3136
Reputation: 117
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!
Upvotes: 0
Reputation: 22280
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.
Upvotes: 1