When using Meteor, should I prefix npm with meteor?

时间:2016-07-11 19:49:28

标签: javascript node.js meteor npm

When working on Meteor 1.3 projects, should I always prefix npm with meteor? In the Meteor documentation and in code examples I see both.

I suspect that I always want to do this:

$ meteor npm install --save some-package

But is there ever a situation, in a Meteor project, where I want to just use the system npm?

$ npm install --save some-package

Are people just using shorthand when they omit the meteor prefix?

2 个答案:

答案 0 :(得分:0)

At least there is no difference in using a global npm or the meteor encapsulated. For me, I always use meteor npm or meteor node because I do not need and do not want to install global software.

Also to know, the bundled node is always the release with best tested compatibility and so I always use that. Also on production environment, we have installed meteor and use the bundled npm and node when running our apps. No issues by now.

I also like to have all project related stuff inside the project folder and not globally. That means, that we do not install anything npm related globally but always local to the node-modules folder.

This gives us the opportunity to move and run our software on different self hosting environments without headages or compatibility issues even between projects with different releases on same system.

Be aware that before release 1.3.4.3 the meteor tool does not respect always latest tools but this is solved by now.

Cheers Tom

答案 1 :(得分:0)

嗯,确切地说,这取决于你想要做什么。

简单的理由基于汤姆在答案中没有明确说出的内容:

  • $ meteor npm install …将使用随Meteor Tools发布/捆绑的本地npm。它是Meteor官方支持的版本。
  • $ npm install …将使用您的全球npm,该版本可能与Meteor的版本不同。

npm的情况下,差异可能不明显。

不幸的是,Node的情况有所不同:Meteor 1.3仍然依赖Node 0.10.43 !只需尝试使用命令$ meteor node --version$ node --version

Meteor 1.4应该升级到Node 4.

知道这一点,你仍然可以使用$ node(没有meteor前缀),只要你的脚本不需要稍后由Meteor本身执行(通常是通过构建过程)。即使它确实如此,如果您的脚本不使用高级节点功能(即在版本0.10.43之后引入),也不会有麻烦。