Jankapunkt
Jankapunkt

Reputation: 8423

How to call a global npm command in Meteor?

Background

Meteor is shipped with a packaged npm. Calling any npm related commands requires the following pattern:

meteor npm [command]

I installed a global npm package (npm-install-missing):

meteor npm install -g npm-install-missing

Problem

It is intended to be called as a toplevel command:

Usage

Within your project directory:

npm-install-missing The script will check the current project directory for missing dependencies and install them automatically.

So I tried inside my project dir the some possible variations of calling it:

1. meteor npm-install-missing

Obviously as calling npm via meteor using the meteor command in before. Turned out to be wrong:

> meteor npm-install-missing

> 'npm-install-missing' is not a Meteor command. See 'meteor --help'.

2. npm-install-missing (without meteor command)

Ok, so maybe it is top-level installed and I can call it like so. Turned out to be wrong, too.

> npm-install-missing
> npm-install-missing is not recognized as an internal or external command

3. meteor npm run npm-install-missing

Obviously wrong, because I have no script in my package.json but I gave it a try anyway. Turned out to be wrong:

> meteor npm run npm-install-missing
> npm ERR! missing script: npm-install-missing

Question

How can I call this package without additionally installing nodejs and npm?

Upvotes: 0

Views: 987

Answers (1)

Jankapunkt
Jankapunkt

Reputation: 8423

Okay turned out to be too easy, but for documentation purposes I want to share my result.

Just install global commands (such as in my case npm-install-missing) also with the --save option.

meteor npm install -g --save npm-install-missing

Then you can call it globally in any of your meteor projects like npm itself:

meteor npm-install-missing

Background

Without the --save option, it would be installed in the npm-cache subdir of meteor's Roaming AppData but not linked to the bin folder of the meteor tool. This is the folder where meteor looks for these global commands to be called.

The folder is in windows:

AppData\Local\.meteor\packages\meteor-tool\1.4.4_2\mt-os.windows.x86_32\dev_bundle\bin\node_modules

Without --save it hasn't been installed there.

Upvotes: 1

Related Questions