Questions tagged [npm-scripts]

The "scripts" property of the package.json file supported by npm.

The "scripts" property of the file is a dictionary containing script commands that are run at various times in the lifecycle of your package. The key is the lifecycle event, and the value is the command to run at that point.

supports the "scripts" property of the package.json file, for the following scripts:

  • prepublish: Run BEFORE the package is packed and published, as well as on local npm install without any arguments. (See below)
  • prepare: Run both BEFORE the package is packed and published, and on local npm install without any arguments (See below). This is run AFTER prepublish, but BEFORE prepublishOnly.
  • prepublishOnly: Run BEFORE the package is prepared and packed, ONLY on npm publish. (See below.)
  • 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.
  • preversion: Run BEFORE bumping the package version.
  • version: Run AFTER bumping the package version, but BEFORE commit.
  • postversion: Run AFTER bumping the package version, and AFTER commit.
  • 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 no restart script is provided.
  • preshrinkwrap, shrinkwrap, postshrinkwrap: Run by the npm shrinkwrap command.

Additionally, arbitrary scripts can be executed by running npm run-script <stage>. Pre and post commands with matching names will be run for those as well (e.g. premyscript, myscript, postmyscript). Scripts from dependencies can be run with npm explore <pkg> -- npm run <stage>.

To find more information :

1068 questions
-1
votes
1 answer

NPM start script missing

I am trying to use the npm start command but I don't have the correct "start" script in my package.json. Can anyone please tell me the correct way to add it? I have tried adding "start": "node server.js" to my scripts in package.json but that throws…
Aristophanes
  • 475
  • 1
  • 9
  • 21
-1
votes
1 answer

How can npm know how to update `package.json` after run `npm install xx`, `npm uninstall xx`

I am very curious about it , but don't know how can it know where to insert or delete package name ?
Dearest
  • 107
  • 1
  • 7
-1
votes
1 answer

what does "additional logging output above" mean in npm?

"This is probably not a problem with npm. There is likely additional logging output above". What does this mean and how can I resolve this error? It also shows the following: npm ERR! code ELIECYCLE npm ERR! errno 1
Arpan Nand
  • 39
  • 1
-1
votes
2 answers

Node.js Error while installing npm install node modules

I have to install node.js in my project for node modules while installing node modules its showing below error. How to rectifies this error. Note: I ran npm run clean and delete my node modules folder and again ran npm install but did not work…
kiran kumar
  • 31
  • 1
  • 4
-2
votes
1 answer

can't use npm at all

so I just downloaded node from the website, node works just perfect but the thing is whenever I try to use npm command in terminal it doesn't work and throws this Error Also, I tried to update npm but it seems it won't work since I can't use the npm…
Ab Arabi
  • 3
  • 1
  • 5
-2
votes
1 answer

ERROR command failed: npm install --loglevel error @vue/cli-plugin-babel@~4.5.0 @vue/cli-plugin-eslint@~4.5.0 @vue/cli-service@~4.5.0 --save-dev

ERROR command failed: npm install --loglevel error @vue/cli-plugin-babel@~4.5.0 @vue/cli-plugin-eslint@~4.5.0 @vue/cli-service@~4.5.0 --save-dev
kavita
  • 3
  • 1
-2
votes
1 answer

Npm missing script: start-win

Getting the below error log after executing npm run start-win: 0 info it worked if it ends with ok 1 verbose cli [ 'C:\\Program Files\\nodejs\\node.exe', 1 verbose cli 'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js', 1 verbose cli…
Zayidu A
  • 13
  • 2
  • 7
-2
votes
1 answer

npm script error while trying to install react-router-dom

While working on my react project, I just tried to install react-router-dom and somehow it seems it erased all my scripts and modules. Now I cannot run the server again no matter what I do. I also cleaned working directories and even deleted the…
Jay Jeong
  • 892
  • 2
  • 11
  • 24
-2
votes
2 answers

"node run dev" can't work ,how to fix it?

I want to run "truffle serve" which linked to localhost:8080. But get this error message Then I tried to find the problem which may be the version of truffle. I tried "npm run dev". But failed with this message. How can I solve the problem?, please…
jianwei
  • 3
  • 5
-3
votes
0 answers

How to create a monorepo js library that relies on a third-party tool library

How to create a monorepo js library that relies on a third-party tool library import printJS from 'print-js'; export const usePrint = (id: string) => { printJS({ printable: id, type: 'html', targetStyles: ['*'], ...options …
laterday
  • 353
  • 1
  • 4
  • 11
-3
votes
1 answer

Is there solution for localhost error 404?

I tried to access my file on localhost, but it shows an error like below: Not Found 404 NotFoundError: Not Found at C:\Users\RMUSER1\Desktop\Rainbowmedia\test1\billing-bakery\app.js:50:8 at Layer.handle [as handle_request]…
muthu
  • 1
  • 1
-3
votes
1 answer

Package not found - Problems with a project in Vue3

I'm learning Vue3, but I'm with some problems when I try to create the project. I'm using Windows 10 and the more update versions of node and vue. This is my steps. Initial configs Create app Starting server The error message I'm try update node and…
Benedito
  • 1
  • 1
-3
votes
1 answer

cesiumjs and react app with craco start not working

I'm using npm "craco" in order to use "Resium" which is a react help library for cesiumjs maps. npm craco I've copied all the files (except node_modules) to another folder, running npm i and npm start and it failed with these errors. (The original…
-3
votes
1 answer

Is there any "middleware" or npm package Convert flat JSON file to hierarchical json data?

I want convert flat-Json to hierarchical, or I'm converting excel to Json first and then try to make JSON Object hierarchy. I want convert flat-Json to hierarchical json object of nth level. Is there any middleware that conver Flat JSON to…
-3
votes
1 answer

Is it possible to run any computer command with `npm install`?

After noticing that installing bcrypt runs several commands like CMake. I was wondering if it is possible to run: File management commands (copy, create, delete) Other NPM commands (install, update, publish, etc) Potentially malicious code (rm -rf,…
adelriosantiago
  • 7,762
  • 7
  • 38
  • 71
1 2 3
71
72