2016-11-09 106 views
0

我正在使用Express創建Node.js應用程序。通常,爲了在本地運行應用程序,我輸入node app.js,並且一切正常。不過,現在我用一本書來學習如何創建快遞的應用程序,它要求我創建具有在它下面的一個斌/ WWW文件:'nodejs'未被識別爲內部或外部命令

#!/usr/bin/nodejs 
var debug = require('debug')('my-application'); 
var app = require('../app'); 

app.set('port', process.env.PORT || 3000); 

var server = app.listen(app.get('port'), function() { 
    debug('Express server listening on port ' + server.address().port); 
}); 

書中還問我要安裝nodemon運行該應用程序。然而,每次我用npm startnodemon啓動應用程序時,我得到的錯誤:

'nodejs' is not recognized as an internal or external command

環境變量設置正確,我仔細檢查過。

這裏的調試日誌:

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 [email protected] 
3 info using [email protected] 
4 verbose run-script [ 'prestart', 'start', 'poststart' ] 
5 info prestart [email protected] 
6 info start [email protected] 
7 verbose unsafe-perm in lifecycle true 
8 info [email protected] Failed to exec start script 
9 verbose stack Error: [email protected] start: `nodejs ./bin/www` 
9 verbose stack Exit status 1 
9 verbose stack  at EventEmitter.<anonymous> (C:\Program Files\nodejs\node_modules\npm\lib\utils\lifecycle.js:217:16) 
9 verbose stack  at emitTwo (events.js:87:13) 
9 verbose stack  at EventEmitter.emit (events.js:172:7) 
9 verbose stack  at ChildProcess.<anonymous> (C:\Program Files\nodejs\node_modules\npm\lib\utils\spawn.js:24:14) 
9 verbose stack  at emitTwo (events.js:87:13) 
9 verbose stack  at ChildProcess.emit (events.js:172:7) 
9 verbose stack  at maybeClose (internal/child_process.js:827:16) 
9 verbose stack  at Process.ChildProcess._handle.onexit (internal/child_process.js:211:5) 
10 verbose pkgid [email protected] 
11 verbose cwd C:\Users\Humad\Dropbox\projects\loc8r 
12 error Windows_NT 10.0.14393 
13 error argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "start" 
14 error node v4.4.7 
15 error npm v2.15.8 
16 error code ELIFECYCLE 
17 error [email protected] start: `nodejs ./bin/www` 
17 error Exit status 1 
18 error Failed at the [email protected] start script 'nodejs ./bin/www'. 
18 error This is most likely a problem with the application-name package, 
18 error not with npm itself. 
18 error Tell the author that this fails on your system: 
18 error  nodejs ./bin/www 
18 error You can get information on how to open an issue for this project with: 
18 error  npm bugs application-name 
18 error Or if that isn't available, you can get their info via: 
18 error 
18 error  npm owner ls application-name 
18 error There is likely additional logging output above. 
19 verbose exit [ 1, true ] 
+1

將您的'start'命令改爲使用'node',而不是'nodejs'。 – SLaks

回答

2

你似乎(通過鍵入node app.js)已經知道,Windows中的節點過程node,不nodejs

將package.json中的start命令更改爲正確的命令。

相關問題