English 中文(简体)
2. 定点灯。
原标题:set node.js REPL module paths
  • 时间:2011-05-05 05:19:15
  •  标签:
  • node.js
  • npm

我可以说明如何在我的Node.js安装(在MacOS X上,第0.4.7段)。 I ve 安装了npm,在全球安装了/usr/ local/lib/node_modules。 然而,当我安装了 n时,它没有通知诺德,它选择了什么地方来建立全球单元(它是否拥有)。 现在,当我使用诺德的指挥模式时,我只能使用<条码>查询(<>/条码>我的全球组合模块。 因此,我不禁要问,在我能够补充我的全球npm模块安装道路的地方,是否存在着某种Node配置文档或环境变量?

我知道,我只能添加到<条码>查询。 在诺德指挥线一米时的阵列,但我想一劳永逸地补充这一全球单元,以便诺德总是在I <代码>要求()从指挥线查询单元的目录。 事先感谢任何帮助和点人,让他们 n子和诺德ist子。

最佳回答
问题回答

在全球安装一个包裹(通常由指挥线使用)

www.un.org/french/ga PACKAGE_NAME

在我的案件中,我谨安装<编码>jslint作为指挥线工具。 因此,我

<代码>npm 安装——全球jslint

这套设备将安装在包件上。

因此,所有这一切为什么? 如果在某个项目中重新使用,你就没有在全球安装成套设备。

欲了解更多情况,请查阅帮助页。

<代码>npm=全球

我还在<代码>npmFAQ

In reply to this: https://stackoverflow.com/a/5923898/7381355

You can add this to your .bashrc to only set NODE_PATH when running the repl since requiring global modules is an anti-pattern.

node() {
  if (( $# == 0 )); then
    NODE_PATH=$(npm root -g) command node
  else
    command node "$@"
  fi
}

It sets NODE_PATH when no arguments are passed to node. So it wouldn t work with something like node -i. You would have to add more argument checking to cover all cases a repl is run.

This would make the repl always set NODE_PATH. If you want to be able to choose whether to run the repl or a script with global modules or not, you can add this to your .bashrc instead.

node_global() {
  NODE_PATH=$(npm root -g) node "$@"
}

然后,就跑了 no子——全球。 我采用了第二种选择。





相关问题
How to make Sequelize use singular table names

I have an model called User but Sequelize looks for the table USERS whenever I am trying to save in the DB. Does anyone know how to set Sequelize to use singular table names? Thanks.

What is Node.js? [closed]

I don t fully get what Node.js is all about. Maybe it s because I am mainly a web based business application developer. What is it and what is the use of it? My understanding so far is that: The ...

Clientside going serverside with node.js

I`ve been looking for a serverside language for some time, and python got my attention somewhat. But as I already know and love javascript, I now want learn to code on the server with js and node.js. ...

Can I use jQuery with Node.js?

Is it possible to use jQuery selectors/DOM manipulation on the server-side using Node.js?

How do I escape a string for a shell command in node?

In nodejs, the only way to execute external commands is via sys.exec(cmd). I d like to call an external command and give it data via stdin. In nodejs there does yet not appear to be a way to open a ...