npm-start

启动一个包

选择命令行版本:

概要

🌐 Synopsis

npm start [-- <args>]

描述

🌐 Description

这会运行包的 "scripts" 对象的 "start" 属性中指定的预定义命令。

🌐 This runs a predefined command specified in the "start" property of a package's "scripts" object.

如果 "scripts" 对象没有定义 "start" 属性,npm 将运行 node server.js

🌐 If the "scripts" object does not define a "start" property, npm will run node server.js.

请注意,这与默认的节点行为不同,默认情况下,当使用 node . 调用时,会运行包的 "main" 属性中指定的文件

🌐 Note that this is different from the default node behavior of running the file specified in a package's "main" attribute when evoking with node .

截至 npm@2.0.0,你可以在执行脚本时使用自定义参数。更多详情请参阅 npm run-script

🌐 As of npm@2.0.0, you can use custom arguments when executing scripts. Refer to npm run-script for more details.

示例

🌐 Example

{
"scripts": {
"start": "node foo.js"
}
}
npm start
> npm@x.x.x start
> node foo.js
(foo.js output would be here)

配置

🌐 Configuration

ignore-scripts

  • 默认:否
  • 类型:布尔

如果为 true,npm 不会运行 package.json 文件中指定的脚本。

🌐 If true, npm does not run scripts specified in package.json files.

请注意,明确用于运行特定脚本的命令,例如 npm startnpm stopnpm restartnpm testnpm run-script,如果设置了 ignore-scripts,仍会运行其指定的脚本,但它们不会运行任何前置或后置脚本。

🌐 Note that commands explicitly intended to run a particular script, such as npm start, npm stop, npm restart, npm test, and npm run-script will still run their intended script if ignore-scripts is set, but they will not run any pre- or post-scripts.

script-shell

  • 默认:在 POSIX 系统上为 '/bin/sh',在 Windows 上为 'cmd.exe'
  • 类型:空或字符串

用于通过 npm execnpm runnpm init <package-spec> 命令运行脚本的 shell。

🌐 The shell to use for scripts run with the npm exec, npm run and npm init <package-spec> commands.

也可以看看

🌐 See Also