gpt4 book ai didi

javascript - 如何使用 npm 脚本运行 js 文件?

转载 作者:IT老高 更新时间:2023-10-28 21:51:01 29 4
gpt4 key购买 nike

我无法让 npm 工作。我的 package.json 文件有

"scripts": { "build": "build.js" }

我在与 console.logs 相同的文件夹中有一个 build.js 文件。

当我运行时

npm run build

我得到了错误

The system cannot execute the specified program.

npm ERR! Windows_NT 6.1.7601
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run" "build"
npm ERR! node v4.1.1
npm ERR! npm v3.3.5
npm ERR! code ELIFECYCLE

如果我移动 build.js 文件并将我的 package.json 文件更改为有一个子文件夹

"scripts": { "build": "build/build.js" }

然后我得到错误

'build' is not recognized as an internal or external command, operable program or batch file.

怎么了?我正在复制 example documentation .

最佳答案

{ "scripts" :
{ "build": "node build.js"}
}

npm run build OR npm run-script build


{
"name": "build",
"version": "1.0.0",
"scripts": {
"start": "node build.js"
}
}

npm start


NB: you were missing the { brackets } and the node command

文件夹结构很好:

+ build
- package.json
- build.js

关于javascript - 如何使用 npm 脚本运行 js 文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32964900/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com