小弟最近在學習nodejs
目前在學習express
https://expressjs.com/en/starter/generator.html
跟著此步驟走走到最後一步執行, set DEBUG=myapp: & npm start,就報錯了
我上網找了許多資料但並無所獲><
懇請大大幫我看一下哪裡有問題
錯誤內容:
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 'start' ]
2 info using npm@3.6.0
3 info using node@v5.7.1
4 verbose run-script [ 'prestart', 'start', 'poststart' ]
5 info lifecycle myapp@0.0.0~prestart: myapp@0.0.0
6 silly lifecycle myapp@0.0.0~prestart: no script for prestart, continuing
7 info lifecycle myapp@0.0.0~start: myapp@0.0.0
8 verbose lifecycle myapp@0.0.0~start: unsafe-perm in lifecycle true
9 verbose lifecycle myapp@0.0.0~start: PATH: C:\Program Files\nodejs\node_modules\npm\bin\node-gyp-bin;C:\Users\daniel\Desktop\nodejs\first\Nodejs-Newbie-Manual-\modulepackage\myapp\node_modules\.bin;C:\Program Files\Git\cmd;C:\ProgramData\Oracle\Java\javapath;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\Microsoft SQL Server\110\Tools\Binn\;C:\Program Files (x86)\Java\jre1.8.0_45\bin;C:\android\android-sdk-windows\platform-tools;C:\android\android-sdk-windows\tools;C:\Program Files\Microsoft SQL Server\120\Tools\Binn\;C:\Program Files (x86)\Windows Kits\8.1\Windows Performance Toolkit\;C:\Program Files (x86)\Skype\Phone\;c:\Program Files (x86)\Microsoft SQL Server\110\Tools\Binn\ManagementStudio\;c:\Program Files (x86)\Microsoft SQL Server\110\Tools\Binn\;c:\Program Files (x86)\Microsoft SQL Server\110\DTS\Binn\;C:\Program Files\Microsoft\Web Platform Installer\;c:\Program Files\Microsoft SQL Server\110\DTS\Binn\;C:\Program Files\Java\jdk1.8.0_45\bin:C:\android\android-sdk-windows\tools;C:\android\android-sdk-windows\platform-tools;C:\Users\daniel\V-PlaySDK\Tools\QtCreator\bin;C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET Web Pages\v1.0\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\Git\cmd;C:\Program Files\TortoiseGit\bin;%USERPROFILE%\.dnx\bin;C:\Program Files\Microsoft DNX\Dnvm\;C:\Program Files\nodejs\;C:\Users\daniel\AppData\Roaming\npm
10 verbose lifecycle myapp@0.0.0~start: CWD: C:\Users\daniel\Desktop\nodejs\first\Nodejs-Newbie-Manual-\modulepackage\myapp
11 silly lifecycle myapp@0.0.0~start: Args: [ '/d /s /c', 'node ./bin/www' ]
12 silly lifecycle myapp@0.0.0~start: Returned: code: 1 signal: null
13 info lifecycle myapp@0.0.0~start: Failed to exec start script
14 verbose stack Error: myapp@0.0.0 start: `node ./bin/www`
14 verbose stack Exit status 1
14 verbose stack at EventEmitter.<anonymous> (C:\Program Files\nodejs\node_modules\npm\lib\utils\lifecycle.js:232:16)
14 verbose stack at emitTwo (events.js:100:13)
14 verbose stack at EventEmitter.emit (events.js:185:7)
14 verbose stack at ChildProcess.<anonymous> (C:\Program Files\nodejs\node_modules\npm\lib\utils\spawn.js:24:14)
14 verbose stack at emitTwo (events.js:100:13)
14 verbose stack at ChildProcess.emit (events.js:185:7)
14 verbose stack at maybeClose (internal/child_process.js:827:16)
14 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:211:5)
15 verbose pkgid myapp@0.0.0
16 verbose cwd C:\Users\daniel\Desktop\nodejs\first\Nodejs-Newbie-Manual-\modulepackage\myapp
17 error Windows_NT 6.1.7601
18 error argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "start"
19 error node v5.7.1
20 error npm v3.6.0
21 error code ELIFECYCLE
22 error myapp@0.0.0 start: `node ./bin/www`
22 error Exit status 1
23 error Failed at the myapp@0.0.0 start script 'node ./bin/www'.
23 error Make sure you have the latest version of node.js and npm installed.
23 error If you do, this is most likely a problem with the myapp package,
23 error not with npm itself.
23 error not with npm itself.
23 error not with npm itself.
23 error Tell the author that this fails on your system:
23 error node ./bin/www
23 error You can get information on how to open an issue for this project with:
23 error npm bugs myapp
23 error Or if that isn't available, you can get their info via:
23 error npm owner ls myapp
23 error There is likely additional logging output above.
24 verbose exit [ 1, true ]
用回答的好了,討論打字的地方有點小,打多一點東西就有點彆扭...
其實我沒有發現問題在哪,所以是用猜的啦XD...你貼出來的npm-debug.log,只告訴你在跑npm start的時候因為發生錯誤而中止,沒有其他資訊可以判斷到底是什麼問題XD,所以我請你直接執行node ./bin/www
另外,myapp裡面這些都是安裝express-generator後,它幫你產生的。它就是設計成這樣,所以照他設計的來就是了。原本跑express,最後會把app丟進http跑:
/**
* Create HTTP server.
*/
var server = http.createServer(app);
/**
* Listen on provided port, on all network interfaces.
*/
server.listen(port);
server.on('error', onError);
server.on('listening', onListening);
但是這部份的程式碼基本上不會變動,會變動的主要是app.js裡面這塊,所以他把這部份拉出來成為./bin/www這個檔,執行這個就可以啟動express,產生專案框架也比較方便。