2013-08-23 50 views
2

這是我的文件test.js包含:從命令行調用腳本的NodeJS不起作用

console.log("Hello Stackoverflow"); 

這是發生了什麼,當我嘗試運行它:

$ ls 
test.js 
$ node test.js 
$ node test 
$ node "test" 
$ node "test.js" 
$ node --debug test.js 
debugger listening on port 5858 
$ node --debug test 
debugger listening on port 5858 
$ 

注意它永遠不會工作:(我可以運行只是「節點」,並逐行評估JavaScript語句,但每當我嘗試運行腳本如上所述,它不起作用。 nodejs。

+0

我不是在Mac上,但我無法重現此(Win 7 x64,節點v0.10.16)。 – 2013-08-23 19:44:42

+0

奇怪..它在這裏工作得很好 – hexist

+0

'node test'不會返回錯誤,這很奇怪。也許'節點'是別名的東西。 – 2013-08-23 22:18:43

回答

2

我的問題的解決方案是使用卸載節點:

sudo rm -rf /usr/local/{bin/{node,npm},lib/node_modules/npm,lib/node,share/man/*/node.*} 

然後我在我的Mac安裝BREW:

ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/go)" 

然後我做了

brew doctor 

我固定它告訴我要解決的問題,然後我做了

brew install node 

然後我重新啓動終端,節點正在工作。