简体   繁体   English

从命令行使用Node JS

[英]Using node js from command line

I'm totally newbie on node.js so let me explain what I'm trying to do: 我对node.js完全是新手,所以让我解释一下我要做什么:

I want to install tail-http https://www.npmjs.com/package/tail-http and in this page it clearly says it is operated: 我想安装tail-http https://www.npmjs.com/package/tail-http,并且在此页面中明确表示已操作:

tail-http http://example.com/some-file.log

After install node and npm I cannot install it an use it as a new command, The far I get was: 在安装节点和npm之后,我无法安装它并将其用作新命令,我得到的是:

$ npm init
$ npm install tail-http
$ cd node_modules
$ cd tail-http
$ node index.js http://example.com/some-file.log

That works, but is far from the simple usage expose on that web. 那行得通,但与该网站上公开的简单用法相去甚远。

What am I missing? 我想念什么?

npm install -g tail-http

将在全球范围内安装它,然后您就可以在任何地方使用它。

Any package installed with -g (global flag) which tells the npm to install globally and available through out the file system. 使用-g(全局标志)安装的任何软件包,它告诉npm全局安装并且可在整个文件系统中使用。 Make sure you logged in as root. 确保您以root用户身份登录。 Most of the times it throws a permission denied error. 在大多数情况下,它会引发权限拒绝错误。 Or just use sudo npm install -g tail-http 或者只是使用sudo npm install -g tail-http

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM