简体   繁体   English

npm-运行package.json时出错

[英]npm - error running package.json

I'm learning nodejs and trying to build a simple console app. 我正在学习nodejs,并尝试构建一个简单的控制台应用程序。 The app is working. 该应用程序正在运行。 However, when I run the package.json below, so that I can build it and install all dependencies easily, a few errors came up. 但是,当我运行下面的package.json以便构建它并轻松安装所有依赖项时,出现了一些错误。 Looks like it failed to install dependencies because if I installed the dependencies first, there wouldn't be a problem. 看起来它无法安装依赖项,因为如果我先安装依赖项,那不会有问题。 Does anyone know what's wrong with my package.json? 有人知道我的package.json有什么问题吗?

Thanks. 谢谢。

{
  "name": "Testing",
  "version": "0.0.1",
  "author": "My Name",
  "description": "testing",
  "scripts": {
    "build-js": "browserify scripts/app.js > scripts/bundle.js"
  },
  "dependencies": {
    "browserify": "*",
    "uniq": "*"
  }
}

When i run npm run build-js , i got the following errors: 当我运行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

My npm-debug.log is 我的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 ]

Do I have to run npm install first to install all dependencies before running npm run build-js ? 我必须先运行npm install来安装所有依赖项,然后再运行npm run build-js吗?

I have a feeling it's the redirection ( > ) that's causing the problem here, either because of the way the command is executed behind the scenes or because the file you're trying to redirect output to already exists. 我感觉是重定向( > )导致了这里的问题,可能是因为命令在后台执行的方式,或者是您尝试将输出重定向到的文件已经存在。

You should probably use browserify 's --outfile / -o option instead: 你或许应该使用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