1NPM-RUN-SCRIPT(1)                                            NPM-RUN-SCRIPT(1)
2
3
4

NAME

6       npm-run-script - Run arbitrary package scripts
7

SYNOPSIS

9         npm run-script <command> [--silent] [-- <args>...]
10
11         alias: npm run
12

DESCRIPTION

14       This  runs  an arbitrary command from a package's "scripts" object.  If
15       no  "command"  is  provided,  it  will  list  the  available   scripts.
16       run[-script]  is  used  by the test, start, restart, and stop commands,
17       but can be called directly, as well. When the scripts  in  the  package
18       are  printed  out,  they're  separated  into  lifecycle  (test,  start,
19       restart) and directly-run scripts.
20
21       As of ` https://blog.npmjs.org/post/98131109725/npm-2-0-0, you can  use
22       custom  arguments when executing scripts. The special option -- is used
23       by getopt https://goo.gl/KxMmtG to delimit the end of the options.  npm
24       will pass all the arguments after the -- directly to your script:
25
26         npm run test -- --grep="pattern"
27
28       The arguments will only be passed to the script specified after npm run
29       and not to any pre or post script.
30
31       The env script is a special built-in command that can be used  to  list
32       environment  variables that will be available to the script at runtime.
33       If an "env" command is defined in your package, it will take precedence
34       over the built-in.
35
36       In  addition  to  the shell's pre-existing PATH, npm run adds node_mod‐
37       ules/.bin to the PATH provided to scripts.  Any  binaries  provided  by
38       locally-installed  dependencies  can  be  used  without  the  node_mod‐
39       ules/.bin prefix. For example, if there is a devDependency  on  tap  in
40       your package, you should write:
41
42         "scripts": {"test": "tap test/\*.js"}
43
44       instead of
45
46         "scripts": {"test": "node_modules/.bin/tap test/\*.js"}
47
48       to run your tests.
49
50       The  actual  shell  your script is run within is platform dependent. By
51       default, on Unix-like systems it is the /bin/sh command, on Windows  it
52       is  the  cmd.exe.  The actual shell referred to by /bin/sh also depends
53       on the system.  As of `  https://github.com/npm/npm/releases/tag/v5.1.0
54       you can customize the shell with the script-shell configuration.
55
56       Scripts  are  run  from the root of the module, regardless of what your
57       current working directory is when you call npm run. If  you  want  your
58       script  to use different behavior based on what subdirectory you're in,
59       you can use the INIT_CWD environment variable,  which  holds  the  full
60       path you were in when you ran npm run.
61
62       npm  run sets the NODE environment variable to the node executable with
63       which npm is executed.  Also,  if  the  --scripts-prepend-node-path  is
64       passed,  the  directory within which node resides is added to the PATH.
65       If --scripts-prepend-node-path=auto  is  passed  (which  has  been  the
66       default in npm v3), this is only performed when that node executable is
67       not found in the PATH.
68
69       If you try to run a script without having a node_modules directory  and
70       it  fails, you will be given a warning to run npm install, just in case
71       you've forgotten.
72
73       You can use the --silent flag to prevent showing  npm  ERR!  output  on
74       error.
75
76       You can use the --if-present flag to avoid exiting with a non-zero exit
77       code when the script is undefined. This lets you run potentially  unde‐
78       fined scripts without breaking the execution chain.
79

SEE ALSO

81       · npm help 7 scripts
82
83       · npm help test
84
85       · npm help start
86
87       · npm help restart
88
89       · npm help stop
90
91       · npm help 7 config
92
93
94
95
96
97                                  April 2019                 NPM-RUN-SCRIPT(1)
Impressum