我跟着nodejs一起以正确的方式跟随着node.js,并且在尝试执行此命令时卡住了。我将#!/ usr / bin / env更改为#!/ usr / bin / node,因为env甚至都不是我的文件夹,而node.js在我相信的节点文件夹中。我正在运行Ubuntu 14.04。解决办法是什么?如果重要的话,我有在后台运行的ouchdb。谢谢
ryan @ Ryan:〜/ Documents / code / databases $ ./dbcli.js module.js:340 throw err; ^ 错误: 在Function.Module._load(module.js:280 )的Function.Module._resolveFilename(module.js:338:15)上找不到模块'/ home / ryan / Documents / code / databases / node --harmony' :25) 在 启动时(node.js:119:16 )在Function.Module.runMain(module.js:497:10 ) 在node.js:935:3
这是程序
#!/usr/bin/node node --harmony
/***
* Excerpted from "Node.js the Right Way",
* published by The Pragmatic Bookshelf.
* Copyrights apply to this code. It may not be used to create training material,
* courses, books, articles, and the like. Contact us if you are in doubt.
* We make no guarantees that this code is fit for any purpose.
* Visit http://www.pragmaticprogrammer.com/titles/jwnode for more book information.
***/
const
request = require('request'),
options = {
method: process.argv[2] || 'GET',
url: 'http://localhost:5984/' + (process.argv[3] || '')
};
request(options, function(err, res, body) {
if (err) {
throw Error(err);
} else {
console.log(res.statusCode, JSON.parse(body));
}
});
因为它解决了您的问题,所以使我的评论成为答案:
最后我检查了一下,#!/usr/bin/node node --harmony
因为无效的Javascript ,所以无法放入传递给节点的.js文件。您可以删除该行并通过键入以下命令手动运行.js文件:
node --harmony dbcli.js
仅供参考,看起来可以执行您尝试做的事情,但是由于您尝试运行,因此您没有使用正确的语法node node
。看到这个答案。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句