npm install
installs the depedendencies in your package.json config.npm run build
runs the script "build" and created a script which runs your application - let's say server.jsnpm start
runs the "start" script which will then be "node server.js"It's difficult to tell exactly what the issue was but basically if you look at your scripts configuration, I would guess that "build" uses some kind of build tool to create your application while "start" assumes the build has been done but then fails if the file is not there.
You are probably using bower or grunt - I seem to remember that a typical grunt application will have defined those scripts as well as a "clean" script to delete the last build.
Build tools tend to create a file in a bin/, dist/, or build/ folder which the start script then calls - e.g. "node build/server.js". When your npm start
fails, it is probably because you called npm clean
or similar to delete the latest build so your application file is not present causing npm start to fail.
npm build's source code - to touch on the discussion in this question - is in github for you to have a look at if you like. If you run npm build
directly and you have a "build" script defined, it will exit with an error asking you to call your build script as npm run-script build
so it's not the same as npm run script
.
I'm not quite sure what npm build
does, but it seems to be related to postinstall and packaging scripts in dependencies. I assume that this might be making sure that any CLI build scripts's or native libraries required by dependencies are built for the specific environment after downloading the package. This will be why link and install call this script.