在Linux上需要('os')。homedir()错误
当我在Linux中执行这个单行脚本作为sudo我得到一个错误,在我的mac osx我不。
var homedir =require('os').homedir();
错误:
testhomedir.js:1 quire, module, __filename, __dirname) { var homedir = require('os').homedir(); ^ TypeError: undefined is not a function at Object.<anonymous> (/home/marco/test/testhomedir.js:1:91) at Module._compile (module.js:460:26) at Object.Module._extensions..js (module.js:478:10) at Module.load (module.js:355:32) at Function.Module._load (module.js:310:12) at Function.Module.runMain (module.js:501:10) at startup (node.js:129:16) at node.js:814:3
有任何想法吗?
正如Robert在评论中指出的,我的sudo使用了另一个版本的节点,而不是我的常规用户。
这个stackoverflow后提供了我的问题的答案
停止所有使用节点的服务并发出命令
n=$(which node);n=${n%/bin/node}; chmod -R 755 $n/bin/*; sudo cp -r $n/{bin,lib,share} /usr/local
这会将活动的使用节点版本复制到全局使用的文件夹中。
- 如果没有req.session.save(),会话将不会保存在Node.js中
- 我如何连接javascript文件并replaceHTML中的引用?
- 在node.js中,如何使用child_process.exec这样一切都可以asynchronous发生?
- 将缓冲区转换为Redis中的string获取Node.js Heroku应用程序
- node.js – 直接从require创build类的实例
- angular度为2的节点,当你在url栏中input路由时,会得到404错误
- 如何在Node.js中从客户端调用服务器端函数(例如,htmlbuttononclick)?
- 节点 – MongoDB:集合使用mongodb驱动程序找不到任何东西。 壳牌确实返回价值
- Nodemailer:错误连接超时