2016-09-15 108 views
1

我需要一些幫助。我正在學習用node.js構建一個網站。 我已經安裝了節點v4.5.0,npm 2.15.9,coffeescript 1.10.0 我正在按照一本書「CoffeeScript和Node.js」的說明操作。 我有這個文件package.jsonnpm ERR!無關:[email protected]

{ 
    "name": "todo", 
    "version": "0.0.1", 
    "private": true, 
    "scripts": { 
     "start": "node app" 
    }, 
    "dependencies": { 
     "express": "3.0.0beta6", 
     "jade": "*", 
     "socket.io": "*", 
     "coffee-script": "*", 
     "connect-assets": "*" 
    } 
} 

我跑的命令:npm install,此後被證明一些警告,約jade被棄用,而pug必須安裝。 我在package.json文件中將jade更改爲pug,並再次運行npm install。再次有一些警告,關於pug的更新版本!再次做了一些改變,最後這個ERR出現了! 我會感謝一些幫助,如何繼續。

說明:示例代碼來自相當老的一本書(2012),並且從未更新過 我該如何繼續?我有一個jadepug的目錄樹。這會工作嗎?或者我應該更新node和/或npm

編輯:我現在大部分工作,但另一個問題出現了。它應該與以前的有關嗎? 問題:我安裝了另一個輔助模塊:npm install supervisor -g。當我運行supervisor app.coffee時,首先一切看起來都正確,但是在對其中一個文件進行更改後,控制檯顯示變得瘋狂。我必須停止它,這是什麼出來:

Starting child process with 'coffee.cmd app.coffee' 
Listening on port 3000 
events.js:141 
     throw er; // Unhandled 'error' event 
    ^

Error: listen EADDRINUSE :::3000 
    at Object.exports._errnoException (util.js:907:11) 
    at exports._exceptionWithHostPort (util.js:930:20) 
    at Server._listen2 (net.js:1250:14) 
    at listen (net.js:1286:10) 
    at Server.listen (net.js:1382:5) 
    at Function.app.listen (C:\Examples\todo_node\todo\node_modules\express\lib\application.js:533:24) 
    at Object.<anonymous> (C:\Examples\todo_node\todo\app.coffee:13:5) 
    at Object.<anonymous> (C:\Examples\todo_node\todo\app.coffee:1:1) 
    at Module._compile (module.js:409:26) 
    at Object.exports.run (C:\Users\ad\AppData\Roaming\npm\node_modules\coffee-script\lib\coffee-script\coffee-script.js:134:23) 
    at compileScript (C:\Users\ad\AppData\Roaming\npm\node_modules\coffee-script\lib\coffee-script\command.js:224:29) 
    at compilePath (C:\Users\ad\AppData\Roaming\npm\node_modules\coffee-script\lib\coffee-script\command.js:174:14) 
    at Object.exports.run (C:\Users\ad\AppData\Roaming\npm\node_modules\coffee-script\lib\coffee-script\command.js:98:20) 
    at Object.<anonymous> (C:\Users\ad\AppData\Roaming\npm\node_modules\coffee-script\bin\coffee:7:41) 
    at Module._compile (module.js:409:26) 
    at Object.Module._extensions..js (module.js:416:10) 
    at Module.load (module.js:343:32) 
    at Function.Module._load (module.js:300:12) 
    at Function.Module.runMain (module.js:441:10) 
    at startup (node.js:139:18) 
    at node.js:974:3 

Program coffee.cmd app.coffee exited with code 1 

Starting child process with 'coffee.cmd app.coffee' 
Received SIGINT, killing child process... 
Parent process exiting, terminating child... 

第二編輯;我讀過Error: listen EADDRINUSE :::3000表示3000地址正在使用中。我不知道可能會用什麼,但我想知道如何避免這種情況。我在Windows 10上運行這個應用程序,它今天剛剛更新。 而且,我使用命令coffee app.coffee運行應用程序沒有任何問題。缺點是每次文件更改時都必須關閉並重新啓動。

我希望有人能幫助我進一步,

謝謝 廣告

+0

那麼關於你的第二個問題,打開一個具有管理員身份的Windows控制檯並使用「netstat -bano」。搜索端口3000,您將看到使用該端口的進程。 關於第一個問題,不要忘了標記爲完成後的回答,並打開第二篇文章來描述第二個問題(因爲我從現在開始沒有看到您的編輯)。 – Aethyn

回答

1

玉是哈巴狗模板引擎的舊名。
使用帕格,最新版本是2.0.0-B6: Pug page on NPM

,您可以嘗試在頁面上,在瀏覽器中。
如果NPM失敗,請嘗試GitHub repository

如果你不熟悉的版本,只需使用:

npm install pug --save 

自動添加帕格到您的package.json(用正確的,最新的版本)。

編輯:你有哪些警告/錯誤?你可以發佈它嗎?
編輯2:您的快速版本也已過時。

相關問題