npm package.json scripts not being called
From the documentation:
npm supports the "scripts" member of the package.json script, for the following scripts:
prepublish: Run BEFORE the package is published. (Also run on local
npm install
without any arguments.)prepare: Run both BEFORE the package is packed and published, on local
npm install
without any arguments, and when installing git dependencies (See below). This is run AFTERprepublish
, but BEFOREprepublishOnly
.prepublishOnly: Run BEFORE the package is prepared and packed, ONLY on
npm publish
.prepack: run BEFORE a tarball is packed (on
npm pack
,npm publish
, and when installing git dependencies).postpack: Run AFTER the tarball has been generated and moved to its final destination.
publish, postpublish: Run AFTER the package is published.
preinstall: Run BEFORE the package is installed
install, postinstall: Run AFTER the package is installed.
preuninstall, uninstall: Run BEFORE the package is uninstalled.
postuninstall: Run AFTER the package is uninstalled.
preupdate: Run BEFORE the package is updated with the update command.
update, postupdate: Run AFTER the package is updated with the update command.
pretest, test, posttest: Run by the
npm test
command.prestop, stop, poststop: Run by the
npm stop
command.prestart, start, poststart: Run by the
npm start
command.prerestart, restart, postrestart: Run by the
npm restart
command. Note:npm restart
will run the stop and start scripts if norestart
script is provided.Additionally, arbitrary scripts can be run by doing
npm run-script <stage> <pkg>
.
You can see the reason why your npm test
script works is because npm test
is a built-in command. You must use npm run-script
if you want to execute a script that is not executed by a built-in npm command.
Custom scripts declared in the package.json can be ran with the npm run <your-script>
form in your shell.
Try npm run seed
or npm run test
To execute the custom scripts in package.json using below
npm run-script seed
or
npm run-script < custom script >
or you can use
npm run < custom script >