如何诊断此错误?
How to diagnose this error?
我正在尝试 运行 voxel-hello-world(类似 Minecraft 的游戏,运行 在浏览器中)。当我尝试访问本地主机的页面时出现以下错误:
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)here。
我没有使用 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 尝试执行命令 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
beefy 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
快速解决方法:编辑 voxel-hello-world/node_modules/beefy/index.js
,替换此行(第 64 行?):
bfy = spawn(browserify_path, args)
与
bfy = spawn(browserify_path, args, {shell: true})
,然后npm start
,在chrome
中打开
我在 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
beefy
spawns 命令行 browserify
没有 shell,这适用于 Linux,因为 node_modules/.bin/browserify
是一个有效的可执行文件。但是Windows无法执行。
添加选项{shell: true}
是启动一个shell(cmd.exe
)和运行里面的命令,browserify
解析为批处理文件browserify.cmd
在 shell.
不需要browserify
或其他软件包的全局安装,npm start
和其他npm
脚本会自动将本地软件包的可执行文件添加到PATH
。
我正在尝试 运行 voxel-hello-world(类似 Minecraft 的游戏,运行 在浏览器中)。当我尝试访问本地主机的页面时出现以下错误:
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)here。
我没有使用 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 尝试执行命令 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 beefy 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
快速解决方法:编辑 voxel-hello-world/node_modules/beefy/index.js
,替换此行(第 64 行?):
bfy = spawn(browserify_path, args)
与
bfy = spawn(browserify_path, args, {shell: true})
,然后npm start
,在chrome
我在 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
beefy
spawns 命令行 browserify
没有 shell,这适用于 Linux,因为 node_modules/.bin/browserify
是一个有效的可执行文件。但是Windows无法执行。
添加选项{shell: true}
是启动一个shell(cmd.exe
)和运行里面的命令,browserify
解析为批处理文件browserify.cmd
在 shell.
不需要browserify
或其他软件包的全局安装,npm start
和其他npm
脚本会自动将本地软件包的可执行文件添加到PATH
。