2014年1月22日 星期三

npm ERR! Error: CERT_UNTRUSTED

在進行npm安裝的時候,發現錯誤訊息:

npm ERR! Error: CERT_UNTRUSTED

經過Google後,在此得到解答:https://groups.google.com/forum/#!msg/nodejs/aonVboqx8wM/QbwEZFEUDxcJ

只需輸入指令:npm config set ca ""

詳細內容請參考:

  1. https://github.com/npm/npm/issues/1580#issuecomment-2486457
  2. https://github.com/npm/npm/issues/4249

2014年1月2日 星期四

Node版本不同產生的問題

這幾天和David,Simon一起研究websocket的應用,
在我寫好websocket的server時,分享給David進行測試安裝,
不過在他的機器運行時,出現以下的錯誤訊息:

TypeError: Arguments to path.join must be strings at path.js:360:15 at Array.filter (native) at exports.join (path.js:358:36) at exports.send (/root/Ethan/WebSocket-Example-for-Device-By-Server-Side/node_modules/express/node_modules/connect/lib/middleware/static.js:129:20) at ServerResponse.res.sendfile (/root/Ethan/WebSocket-Example-for-Device-By-Server-Side/node_modules/express/lib/response.js:186:3) at /root/Ethan/WebSocket-Example-for-Device-By-Server-Side/server.js:23:9 at callbacks (/root/Ethan/WebSocket-Example-for-Device-By-Server-Side/node_modules/express/lib/router/index.js:272:11) at param (/root/Ethan/WebSocket-Example-for-Device-By-Server-Side/node_modules/express/lib/router/index.js:246:11) at param (/root/Ethan/WebSocket-Example-for-Device-By-Server-Side/node_modules/express/lib/router/index.js:243:11) at pass (/root/Ethan/WebSocket-Example-for-Device-By-Server-Side/node_modules/express/lib/router/index.js:253:5)

但是在我的測試機確是運作正常的,所以開始請教Google大神,
找到了這篇解答:stackOverflow
才知道原來是node版本的關係,在res.sendfile時,
在Node JS v0.10.0以上的,需要使用 res.sendfile('file.ext', {root: __dirname})
這種方式才不會出錯,我的測試機Node版本為v0.8,所以可以用
res.sendfile(__dirname + 'file.ext') 這種寫法。
先寫筆記下來,若有不正確地方請各位大大指教,感謝!