出现这个错误表示端口绑定失败,需要提高权限来运行程序。
分类目录归档:NodeJs
error: unknown type name ‘Arguments’; did you mean ‘v8::internal::Arguments’
我在安装 webkit-devtools-agent 模块的时候node-gyp rebulid过程中碰到了这个错误,node版本为0.12.7。
解决方案
把node换成版本为0.10.x的就可以通过编译了。
Error: Cannot find module ‘npmlog’
手动安装node的时候一不注意就会出现这个错误,装好了之后使用命令 npm 测试一下出来了这个错误: Error: Cannot find module 'npmlog' 。
这一般是放在/bin里的链接不对导致的。
可能情况1
链接指向的不是 node_modules/npm/bin/npm-cli.js ,初次手动安装难免会搞不清要链接哪个文件,把链接指向正确的位置即可。
情况2
使用的不是软链接,由于npm-cli.js中使用的是相对路径,要是你一不小心链了个硬链接,那么npm就会从/bin解析相对路径,所以就找不到npmlog模块了。要使用软链接,在ln命令后加上 -s 选项: ln -s node_modules/npm/bin/npm-cli.js /bin/npm
解决node无法调用全局模块的问题
刚刚我把SPDY装到全局, npm -g install spdy ,
1 2 3 4 5 6 |
spdy@2.0.4 /usr/local/lib/node_modules/spdy ├── http-deceiver@1.2.4 ├── handle-thing@1.2.4 ├── select-hose@2.0.0 ├── debug@2.2.0 (ms@0.7.1) └── spdy-transport@1.1.8 (obuf@1.1.1, wbuf@1.7.0, hpack.js@2.1.4, readable-stream@2.0.2) |
可以看到这个模块被装到/usr/local/lib/node_modules里了
然后开个环境测试一下,结果
1 2 3 4 5 6 7 8 9 10 11 12 |
> require('spdy') Error: Cannot find module 'spdy' at Function.Module._resolveFilename (module.js:336:15) at Function.Module._load (module.js:286:25) at Module.require (module.js:365:17) at require (module.js:384:17) at repl:1:1 at REPLServer.defaultEval (repl.js:154:27) at bound (domain.js:254:14) at REPLServer.runBound [as eval] (domain.js:267:12) at REPLServer.<anonymous> (repl.js:308:12) at emitOne (events.js:77:13) |
吓得我满脑子都是doge!!!这是为什么?
【node】用ws模块创建加密的ws服务(wss)
使用Node.js建立WebSocket服务器
node上有多种websocket模块可以选择,本文推荐模块 ws ,因为它不需要在客户端挂额外的js文件。
不像 socket.io 模块, ws 是一个单纯的websocket模块,不提供向前兼容(也就是fallback),使用最新浏览器的原生Websocket API即可通信。