簡體   English   中英

npm-運行package.json時出錯

[英]npm - error running package.json

我正在學習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嗎?

我感覺是重定向( > )導致了這里的問題,可能是因為命令在后台執行的方式,或者是您嘗試將輸出重定向到的文件已經存在。

你或許應該使用browserify--outfile / -o選項,而不是:

"scripts": {
    "build-js": "browserify scripts/app.js -o scripts/bundle.js"
},

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM