我正在学习nodejs并尝试构建一个简单的控制台应用程序。该应用程序正在运行但是,当我运行下面的package.json,以便我可以轻松地构建它并安装所有依赖项时,会出现一些错误。看起来它无法安装依赖项,因为如果我首先安装了依赖项,那么就不会有问题。有谁知道我的package.json有什么问题?
感谢。
{
"name": "Testing",
"version": "0.0.1",
"author": "My Name",
"description": "testing",
"scripts": {
"build-js": "browserify scripts/app.js > scripts/bundle.js"
},
"dependencies": {
"browserify": "*",
"uniq": "*"
}
}
当我运行npm run build-js
时,我收到以下错误:
npm ERR! Windows_NT 6.1.7601
npm ERR! argv "C:\\Program Files\\nodejs\\\\node.exe" "C:\\Program Files\\node
\\node_modules\\npm\\bin\\npm-cli.js" "run" "build-js"
npm ERR! node v0.12.2
npm ERR! npm v2.7.4
npm ERR! code ELIFECYCLE
npm ERR! Testing@0.0.1 build-js: `browserify scripts/app.js > scripts/bundle.j
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the Testing@0.0.1 build-js script 'browserify scripts/app.j
> scripts/bundle.js'.
npm ERR! This is most likely a problem with the Testing package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! browserify scripts/app.js > scripts/bundle.js
npm ERR! You can get their info via:
npm ERR! npm owner ls Testing
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! C:\Users\vinh.ngo\Desktop\react-play\npm-debug.log
我的npm-debug.log是
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 'run',
1 verbose cli 'build-js' ]
2 info using npm@2.7.4
3 info using node@v0.12.2
4 verbose node symlink C:\Program Files\nodejs\\node.exe
5 verbose run-script [ 'prebuild-js', 'build-js', 'postbuild-js' ]
6 info prebuild-js Testing@0.0.1
7 info build-js Testing@0.0.1
8 verbose unsafe-perm in lifecycle true
9 info Testing@0.0.1 Failed to exec build-js script
10 verbose stack Error: Testing@0.0.1 build-js: `browserify scripts/app.js > scripts/bundle.js`
10 verbose stack Exit status 1
10 verbose stack at EventEmitter.<anonymous> (C:\Program Files\nodejs\node_modules\npm\lib\utils\lifecycle.js:213:16)
10 verbose stack at EventEmitter.emit (events.js:110:17)
10 verbose stack at ChildProcess.<anonymous> (C:\Program Files\nodejs\node_modules\npm\lib\utils\spawn.js:14:12)
10 verbose stack at ChildProcess.emit (events.js:110:17)
10 verbose stack at maybeClose (child_process.js:1015:16)
10 verbose stack at Process.ChildProcess._handle.onexit (child_process.js:1087:5)
11 verbose pkgid Testing@0.0.1
12 verbose cwd C:\Users\vinh.ngo\Desktop\react-play
13 error Windows_NT 6.1.7601
14 error argv "C:\\Program Files\\nodejs\\\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run" "build-js"
15 error node v0.12.2
16 error npm v2.7.4
17 error code ELIFECYCLE
18 error Testing@0.0.1 build-js: `browserify scripts/app.js > scripts/bundle.js`
18 error Exit status 1
19 error Failed at the Testing@0.0.1 build-js script 'browserify scripts/app.js > scripts/bundle.js'.
19 error This is most likely a problem with the Testing package,
19 error not with npm itself.
19 error Tell the author that this fails on your system:
19 error browserify scripts/app.js > scripts/bundle.js
19 error You can get their info via:
19 error npm owner ls Testing
19 error There is likely additional logging output above.
20 verbose exit [ 1, true ]
在运行npm install
之前,我是否必须首先运行npm run build-js
来安装所有依赖项?
答案 0 :(得分:0)
我感觉这是导致问题的重定向(>
),或者是因为命令在幕后执行的方式,或者是因为文件你是&#39 ;尝试将输出重定向到已存在。
您应该使用browserify
--outfile
/ -o
选项代替:
"scripts": {
"build-js": "browserify scripts/app.js -o scripts/bundle.js"
},