如何诊断这个错误?

我正在尝试运行voxel-hello-world (一个类似Minecraft的游戏,它在浏览器中运行)。 当我尝试访问localhost中的页面时,出现以下错误:

4 verbose stack Error: voxel-hello-world@0.6.0 start: `beefy test.js:bundle.js 8080` 14 verbose stack Exit status 1 14 verbose stack at EventEmitter. (C:\Program Files\nodejs\node_modules\npm\lib\utils\lifecycle.js:242:16) 14 verbose stack at emitTwo (events.js:106:13) 14 verbose stack at EventEmitter.emit (events.js:191:7) 14 verbose stack at ChildProcess. (C:\Program Files\nodejs\node_modules\npm\lib\utils\spawn.js:40:14) 14 verbose stack at emitTwo (events.js:106:13) 14 verbose stack at ChildProcess.emit (events.js:191:7) 14 verbose stack at maybeClose (internal/child_process.js:852:16) 14 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:215:5) 

详细信息(包括npm-debug.log)可以在这里find。

我没有Node.js的经验。 我怀疑Node.js的版本可能与这个代码兼容,AFAIK是几年前写的。 我尝试了几个旧版本的Node.js,结果相同。

我该如何解决这个错误? 什么是根本原因?

更新1:当我运行beefy test.js:bundle.js ,我得到这个:

 C:\dev\voxel-hello-world>beefy test.js:bundle.js 8080 module.js:457 throw err; ^ Error: Cannot find module 'C:\Users\pisarenko\Documents\dev\voxel-hello-world\node_modules\browserify/bin/args.js' at Function.Module._resolveFilename (module.js:455:15) at Function.Module._load (module.js:403:25) at Module.require (module.js:483:17) at require (internal/module.js:20:19) at setupBrowserify (C:\Users\pisarenko\AppData\Roaming\npm\node_modules\beefy\lib\bundlers\browserify.js:6:19) at onlocalbrowserify (C:\Users\pisarenko\AppData\Roaming\npm\node_modules\beefy\lib\setup-bundlers.js:30:5) at C:\Users\pisarenko\AppData\Roaming\npm\node_modules\beefy\node_modules\resolve\lib\async.js:42:21 at C:\Users\pisarenko\AppData\Roaming\npm\node_modules\beefy\node_modules\resolve\lib\async.js:121:35 at C:\Users\pisarenko\AppData\Roaming\npm\node_modules\beefy\node_modules\resolve\lib\async.js:93:39 at C:\Users\pisarenko\AppData\Roaming\npm\node_modules\beefy\node_modules\resolve\lib\async.js:59:30 

我试图安装browserify …

 C:\Users\pisarenko\Documents\dev\voxel-hello-world>npm install browserify -g C:\Users\pisarenko\AppData\Roaming\npm\browserify -> C:\Users\pisarenko\AppData\Roaming\npm\node_modules\browserify\bin\cmd.js C:\Users\pisarenko\AppData\Roaming\npm `-- browserify@13.1.0 

但是,同样的错误来了。

更新2:将端口更改为8085没有帮助。

 C:\Users\pisarenko\Documents\dev\voxel-hello-world>npm start > voxel-hello-world@0.6.0 start C:\Users\pisarenko\Documents\dev\voxel-hello-world > beefy test.js:bundle.js 8085 listening on 8085 using .\node_modules\.bin\browserify 200 75ms 1.08KB /index.html events.js:160 throw er; // Unhandled 'error' event ^ Error: spawn C:\Users\pisarenko\Documents\dev\voxel-hello-world\node_modules\.bin\browserify ENOENT at exports._errnoException (util.js:1026:11) at Process.ChildProcess._handle.onexit (internal/child_process.js:182:32) at onErrorNT (internal/child_process.js:348:16) at _combinedTickCallback (internal/process/next_tick.js:74:11) at process._tickCallback (internal/process/next_tick.js:98:9) npm ERR! Windows_NT 10.0.10586 npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "start" npm ERR! node v6.4.0 npm ERR! npm v3.10.3 npm ERR! code ELIFECYCLE npm ERR! voxel-hello-world@0.6.0 start: `beefy test.js:bundle.js 8085` npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the voxel-hello-world@0.6.0 start script 'beefy test.js:bundle.js 8085'. npm ERR! Make sure you have the latest version of node.js and npm installed. npm ERR! If you do, this is most likely a problem with the voxel-hello-world package, npm ERR! not with npm itself. npm ERR! Tell the author that this fails on your system: npm ERR! beefy test.js:bundle.js 8085 npm ERR! You can get information on how to open an issue for this project with: npm ERR! npm bugs voxel-hello-world npm ERR! Or if that isn't available, you can get their info via: npm ERR! npm owner ls voxel-hello-world npm ERR! There is likely additional logging output above. npm ERR! Please include the following file with any support request: npm ERR! C:\Users\pisarenko\Documents\dev\voxel-hello-world\npm-debug.log C:\Users\pisarenko\Documents\dev\voxel-hello-world> 

更新3:运行

 npm install beefy npm install browserify 

没有帮助。

更新4:以下是目录voxel-hello-world\node_modules\.bin\

截图

更新5:根据npm --verbose start的输出npm --verbose start npm试图执行命令beefy test.js:bundle.js 8085

 C:\Users\pisarenko\Documents\dev\voxel-hello-world>npm --verbose start npm info it worked if it ends with ok npm verb cli [ 'C:\\Program Files\\nodejs\\node.exe', npm verb cli 'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js', npm verb cli '--verbose', npm verb cli 'start' ] npm info using npm@3.10.3 npm info using node@v6.4.0 npm verb run-script [ 'prestart', 'start', 'poststart' ] npm info lifecycle voxel-hello-world@0.6.0~prestart: voxel-hello-world@0.6.0 npm info lifecycle voxel-hello-world@0.6.0~start: voxel-hello-world@0.6.0 

voxel-hello-world@0.6.0 start C:\ Users \ pisarenko \ Documents \ dev \ voxel-hello-world robusty test.js:bundle.js 8085

当我尝试自己运行该命令时,它找不到该目录中不存在的文件C:\Users\pisarenko\Documents\dev\voxel-hello-world\node_modules\browserify/bin/args.js (见下面的截图)。

 C:\Users\pisarenko\Documents\dev\voxel-hello-world>beefy test.js:bundle.js 8085 module.js:457 throw err; ^ Error: Cannot find module 'C:\Users\pisarenko\Documents\dev\voxel-hello-world\node_modules\browserify/bin/args.js' at Function.Module._resolveFilename (module.js:455:15) at Function.Module._load (module.js:403:25) at Module.require (module.js:483:17) at require (internal/module.js:20:19) at setupBrowserify (C:\Users\pisarenko\AppData\Roaming\npm\node_modules\beefy\lib\bundlers\browserify.js:6:19) at onlocalbrowserify (C:\Users\pisarenko\AppData\Roaming\npm\node_modules\beefy\lib\setup-bundlers.js:30:5) at C:\Users\pisarenko\AppData\Roaming\npm\node_modules\beefy\node_modules\resolve\lib\async.js:42:21 at C:\Users\pisarenko\AppData\Roaming\npm\node_modules\beefy\node_modules\resolve\lib\async.js:121:35 at C:\Users\pisarenko\AppData\Roaming\npm\node_modules\beefy\node_modules\resolve\lib\async.js:93:39 at C:\Users\pisarenko\AppData\Roaming\npm\node_modules\beefy\node_modules\resolve\lib\async.js:59:30 

截图2

快速解决方法:编辑voxel-hello-world/node_modules/beefy/index.js ,replace这一行(第64行):

bfy = spawn(browserify_path, args)

bfy = spawn(browserify_path, args, {shell: true})

,然后npm start ,打开铬

截图

我在git bash中用下面的命令重现了同样的错误:

 $ git clone https://github.com/maxogden/voxel-hello-world $ cd voxel-hello-world/ $ npm -v 3.3.6 $ node -v v6.1.0 $ cmd /c ver Microsoft Windows [Version 6.1.7601] Copyright (c) 2009 Microsoft Corporation. All rights reserved. > exit $ npm i $ npm start 

由于node_modules/.bin/browserify是一个有效的可执行文件,因此可以在Linux上运行。 但是Windows不能执行它。

添加选项{shell: true}是启动一个shell( cmd.exe )并在其中运行命令, browserify将parsing为shell中的batch filebrowserify.cmd

不需要全局安装browserify或其他软件包, npm start和其他npm脚本会自动将本地软件包的可执行文件添加到PATH