2016-08-19 91 views
1

我試圖運行voxel-hello-world(一個類似Minecraft的遊戲,它運行在瀏覽器中)。我收到以下錯誤,當我嘗試在本地主機訪問頁面:如何診斷此錯誤?

4 verbose stack Error: [email protected] 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 
`-- [email protected] 

但後來同樣的錯誤來了。

更新2:更改端口爲8085沒有幫助。

C:\Users\pisarenko\Documents\dev\voxel-hello-world>npm start 

> [email protected] 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! [email protected] start: `beefy test.js:bundle.js 8085` 
npm ERR! Exit status 1 
npm ERR! 
npm ERR! Failed at the [email protected] 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\的內容。

Screenshot

更新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 [email protected] 
npm info using [email protected] 
npm verb run-script [ 'prestart', 'start', 'poststart' ] 
npm info lifecycle [email protected]~prestart: [email protected] 
npm info lifecycle [email protected]~start: [email protected] 

[email protected]啓動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 

Screenshot 2

+1

回購中存在一些似乎相關的問題。也許[這一個](https://github.com/maxogden/voxel-hello-world/issues/26)可能有幫助? – cartant

+0

我試過了,他們推薦。它沒有幫助(見更新3)。有沒有辦法用詳細輸出來運行'npm start'?或者 - 我怎樣才能找出問題('events.js:160')代碼所在的包? –

+1

'npm --verbose start'應該這樣做。 – cartant

回答

4

快速解決方法:編輯voxel-hello-world/node_modules/beefy/index.js,替換該行(第64?):

bfy = spawn(browserify_path, args)

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

,然後npm start,在鉻打開它

Screenshot

我再現相同的錯誤與以下在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 

beefyspawns命令行browserify無殼,這在Linux上工作,因爲node_modules/.bin/browserify是一個有效的可執行文件。但Windows不能執行它。

添加選項{shell: true}是啓動一個外殼(cmd.exe),並在其運行的命令,browserify解析爲在殼中的批處理文件browserify.cmd

browserify或其他包全局安裝不是必需的,npm startnpm腳本會自動添加可執行本地包,以PATH

+0

謝謝。我將獎勵大約約。 2小時(StackOverflow規則)。 –