Lines Matching full:code
42 code {
49 pre > code {
145 …code>npm cache add</code></a></a></li><li><a href="#npm-ci"><a href="../commands/npm-ci.html"><cod…
149 <p>The <code>"scripts"</code> property of your <code>package.json</code> file supports a number
152 <code>npm run-script <stage></code> or <code>npm run <stage></code> for short. <em>Pre<…
153 commands with matching names will be run for those as well (e.g. <code>premyscript</code>,
154 <code>myscript</code>, <code>postmyscript</code>). Scripts from dependencies can be run with
155 <code>npm explore <pkg> -- npm run <stage></code>.</p>
158 <code>"scripts"</code> section of the <code>package.json</code>, simply create another script
160 <pre><code class="language-json">{
167 </code></pre>
168 <p>In this example <code>npm run compress</code> would execute these scripts as
172 …ions. These scripts happen in addition to the <code>pre<event></code>, <code>post<event&g…
173 <code><event></code> scripts.</p>
175 …li><code>prepare</code>, <code>prepublish</code>, <code>prepublishOnly</code>, <code>prepack</code…
177 <p><strong>prepare</strong> (since <code>npm@4.0.0</code>)</p>
180 <p>Runs BEFORE the package is packed, i.e. during <code>npm publish</code>
181 and <code>npm pack</code></p>
184 <p>Runs on local <code>npm install</code> without any arguments</p>
187 <p>Runs AFTER <code>prepublish</code>, but BEFORE <code>prepublishOnly</code></p>
190 <p>NOTE: If a package being installed through git contains a <code>prepare</code>
191 script, its <code>dependencies</code> and <code>devDependencies</code> will be installed, and
196 <p>As of <code>npm@7</code> these scripts run in the background.
197 To see the output, run with: <code>--foreground-scripts</code>.</p>
202 <li>Does not run during <code>npm publish</code>, but does run during <code>npm ci</code>
203 and <code>npm install</code>. See below for more info.</li>
207 <li>Runs BEFORE the package is prepared and packed, ONLY on <code>npm publish</code>.</li>
211 <li>Runs BEFORE a tarball is packed (on "<code>npm pack</code>", "<code>npm publish</code>", and wh…
212 …code>npm run pack</code>" is NOT the same as "<code>npm pack</code>". "<code>npm run pack</code>" …
220 <li>Runs AFTER any operations that modify the <code>node_modules</code> directory IF changes occurr…
225 …code>npm@1.1.71</code>, the npm CLI has run the <code>prepublish</code> script for both <code>npm …
228 …the operating system or architecture of the target system, use a <code>prepublish</code> script. T…
230 <li>Compiling CoffeeScript source code into JavaScript.</li>
231 <li>Creating minified versions of JavaScript source code.</li>
234 <p>The advantage of doing these things at <code>prepublish</code> time is that they can be done onc…
236 <li>You can depend on <code>coffee-script</code> as a <code>devDependency</code>, and thus
240 <li>You don't need to rely on your users having <code>curl</code> or <code>wget</code> or
244 …code>dependencies</code> script is run any time an <code>npm</code> command causes changes to the …
246 <h4 id="npm-cache-add"><a href="../commands/npm-cache.html"><code>npm cache add</code></a></h4>
248 <li><code>prepare</code></li>
250 <h4 id="npm-ci"><a href="../commands/npm-ci.html"><code>npm ci</code></a></h4>
252 <li><code>preinstall</code></li>
253 <li><code>install</code></li>
254 <li><code>postinstall</code></li>
255 <li><code>prepublish</code></li>
256 <li><code>preprepare</code></li>
257 <li><code>prepare</code></li>
258 <li><code>postprepare</code></li>
261 <code>node_modules</code>, in order, with no internal actions happening in between</p>
262 <h4 id="npm-diff"><a href="../commands/npm-diff.html"><code>npm diff</code></a></h4>
264 <li><code>prepare</code></li>
266 <h4 id="npm-install"><a href="../commands/npm-install.html"><code>npm install</code></a></h4>
267 <p>These also run when you run <code>npm install -g <pkg-name></code></p>
269 <li><code>preinstall</code></li>
270 <li><code>install</code></li>
271 <li><code>postinstall</code></li>
272 <li><code>prepublish</code></li>
273 <li><code>preprepare</code></li>
274 <li><code>prepare</code></li>
275 <li><code>postprepare</code></li>
277 <p>If there is a <code>binding.gyp</code> file in the root of your package and you
278 haven't defined your own <code>install</code> or <code>preinstall</code> scripts, npm will
279 default the <code>install</code> command to compile using node-gyp via <code>node-gyp rebuild</code…
280 <p>These are run from the scripts of <code><pkg-name></code></p>
281 <h4 id="npm-pack"><a href="../commands/npm-pack.html"><code>npm pack</code></a></h4>
283 <li><code>prepack</code></li>
284 <li><code>prepare</code></li>
285 <li><code>postpack</code></li>
287 <h4 id="npm-publish"><a href="../commands/npm-publish.html"><code>npm publish</code></a></h4>
289 <li><code>prepublishOnly</code></li>
290 <li><code>prepack</code></li>
291 <li><code>prepare</code></li>
292 <li><code>postpack</code></li>
293 <li><code>publish</code></li>
294 <li><code>postpublish</code></li>
296 <h4 id="npm-rebuild"><a href="../commands/npm-rebuild.html"><code>npm rebuild</code></a></h4>
298 <li><code>preinstall</code></li>
299 <li><code>install</code></li>
300 <li><code>postinstall</code></li>
301 <li><code>prepare</code></li>
303 <p><code>prepare</code> is only run if the current directory is a symlink (e.g. with
305 <h4 id="npm-restart"><a href="../commands/npm-restart.html"><code>npm restart</code></a></h4>
306 <p>If there is a <code>restart</code> script defined, these events are run, otherwise
307 <code>stop</code> and <code>start</code> are both run if present, including their <code>pre</code> …
308 <code>post</code> iterations)</p>
310 <li><code>prerestart</code></li>
311 <li><code>restart</code></li>
312 <li><code>postrestart</code></li>
314 …user-defined"><a href="../commands/npm-run-script.html"><code>npm run <user defined></code><…
316 <li><code>pre<user-defined></code></li>
317 <li><code><user-defined></code></li>
318 <li><code>post<user-defined></code></li>
320 <h4 id="npm-start"><a href="../commands/npm-start.html"><code>npm start</code></a></h4>
322 <li><code>prestart</code></li>
323 <li><code>start</code></li>
324 <li><code>poststart</code></li>
326 <p>If there is a <code>server.js</code> file in the root of your package, then npm
327 will default the <code>start</code> command to <code>node server.js</code>. <code>prestart</code> …
328 <code>poststart</code> will still run in this case.</p>
329 <h4 id="npm-stop"><a href="../commands/npm-stop.html"><code>npm stop</code></a></h4>
331 <li><code>prestop</code></li>
332 <li><code>stop</code></li>
333 <li><code>poststop</code></li>
335 <h4 id="npm-test"><a href="../commands/npm-test.html"><code>npm test</code></a></h4>
337 <li><code>pretest</code></li>
338 <li><code>test</code></li>
339 <li><code>posttest</code></li>
341 <h4 id="npm-version"><a href="../commands/npm-version.html"><code>npm version</code></a></h4>
343 <li><code>preversion</code></li>
344 <li><code>version</code></li>
345 <li><code>postversion</code></li>
347 …">A Note on a lack of <a href="../commands/npm-uninstall.html"><code>npm uninstall</code></a> scri…
348 <p>While npm v6 had <code>uninstall</code> lifecycle scripts, npm v7 does not. Removal of a package…
357 <p>Due to the lack of necessary context, <code>uninstall</code> lifecycle scripts are not implement…
367 suites, then those executables will be added to the <code>PATH</code> for
369 <pre><code class="language-json">{
378 </code></pre>
379 <p>then you could run <code>npm start</code> to execute the <code>bar</code> script, which is
380 exported into the <code>node_modules/.bin</code> directory on <code>npm install</code>.</p>
382 <p>The package.json fields are tacked onto the <code>npm_package_</code> prefix. So,
383 for instance, if you had <code>{"name":"foo", "version":"1.2.5"}</code> in your
385 <code>npm_package_name</code> environment variable set to "foo", and the
386 <code>npm_package_version</code> set to "1.2.5". You can access these variables
387 in your code with <code>process.env.npm_package_name</code> and
388 <code>process.env.npm_package_version</code>, and so on for other fields.</p>
389 <p>See <a href="../configuring-npm/package-json.html"><code>package.json</code></a> for more on pac…
391 <p>Lastly, the <code>npm_lifecycle_event</code> environment variable is set to
396 <code>{"scripts":{"install":"foo.js"}}</code> in your package.json, then you'd
398 <pre><code class="language-bash">process.env.npm_package_scripts_install === "foo.js"
399 </code></pre>
402 <pre><code class="language-json">{
408 </code></pre>
409 <p>then <code>scripts/install.js</code> will be called for the install and post-install
410 stages of the lifecycle. Since <code>scripts/install.js</code> is running for two
412 <code>npm_lifecycle_event</code> environment variable.</p>
415 <pre><code class="language-json">{
422 </code></pre>
424 <p>Scripts are run by passing the line as a script argument to <code>sh</code>.</p>
425 <p>If the script exits with a code other than 0, then this will abort the
432 <li>Don't exit with a non-zero error code unless you <em>really</em> mean it.
436 <a href="../configuring-npm/package-json.html"><code>package.json</code></a> to see all the things …
440 the <code>npm_config_binroot</code> environment variable is set to <code>/home/user/bin</code>, then
441 don't try to install executables into <code>/usr/local/bin</code>. The user
446 <li>Don't use <code>install</code>. Use a <code>.gyp</code> file for compilation, and <code>prepare…
449 there is another option. The only valid use of <code>install</code> or <code>preinstall</code>
452 current working directory is when <code>npm</code> is invoked. If you want your
454 can use the <code>INIT_CWD</code> environment variable, which holds the full path you
455 were in when you ran <code>npm run</code>.</li>