How do you run a js file using npm scripts?
You should use npm run-script build
or npm build <project_folder>
. More info here: https://docs.npmjs.com/cli/build.
{ "scripts" :
{ "build": "node build.js"}
}
npm run build
ORnpm run-script build
{
"name": "build",
"version": "1.0.0",
"scripts": {
"start": "node build.js"
}
}
npm start
NB: you were missing the
{ brackets }
and the node command
folder structure is fine:
+ build
- package.json
- build.js