How can I install npm dependencies manually using meteor - meteor

I need to install npm dependencies described on my packages.json file manually (by manually I mean with a command like npm install or mrt install, that doesn't require to start the app).
I know that meteor-npm creates the npm directory inside packages and that when I start the app using mrt or meteor the npm modules get downloaded.
But I'm writing a test script and I need the modules to be installed before running the tests so I would need to install them as I install standard meteorite modules with mrt install.

In theory this is very easy, because you could just run npm install PACKAGENAME in your project directory. However, this would of course mess up meteor, which will try to interpret the new files as meteor files.
Instead, you have two options:
install in a super directory (they will be found): cd .. && npm install PACKAGENAME
install packages globally: npm install -g PACKAGENAME

Related

Downgrade Firebase 9.6 to 9.2.0

What commands must I follow on the command line to downgrade. I ran uninstall and reinstalled as well as nom i -S firebase#... but now when I reload the app it just crashes.
If you have to install an older version of a package, just specify it
npm install <package>#<version>
For example: npm install firebase#9.2.0
You can also add the --save flag to that command to add it to your package.json dependencies, or --save --save-exact flags if you want that exact version specified in your package.json dependencies.
The install command is documented here: https://docs.npmjs.com/cli/install
If you're not sure what versions of a package are available, you can use:
npm view firebase versions
And npm view can be used for viewing other things about a package too.
https://docs.npmjs.com/cli/view
don't forget to remove .lock file first to rebuilt the depedency
can u give the error messege for us....

meteor npm install --production

What does these lines mean
meteor npm install --production
meteor npm install --save
?
The Docs explains the command meteor npm <pacakge name> So the npm package is install, but what does the flag --production and --save do?
The meteor npm command simply forwards the arguments that follow it to Meteor's bundled npm version, so it behaves as the npm command-line tool.
The basic command is meteor npm <command and arguments.
This basic install command is meteor npm install <package name> rather than meteor npm <package name>.
Its relevant documentation is therefore not the one you referenced in your question, but the npm's CLI tool's (you referenced npm's install package, note the npm install install there).
NPM creates a package.json file and lists the project's dependencies there. You use the --save flag to instruct npm to add the packages installed to the dependencies file and the --production flag to instruct npm to not install its dev-dependencies, which are dependencies that were used for developing and debugging this package, but are not strictly required for its operation in production.
Take the time to familiarize yourself with the tool.
From the CLI docs:
npm install (with no args, in package dir)
npm install [<#scope>/]<name>
npm install [<#scope>/]<name>#<tag>
npm install [<#scope>/]<name>#<version>
npm install [<#scope>/]<name>#<version range>
npm install <tarball file>
npm install <tarball url>
npm install <folder>
alias: npm i
common options: [-S|--save|-D|--save-dev|-O|--save-optional] [-E|--save-exact] [--dry-run]
-S, --save: Package will appear in your dependencies.
With the --production flag (or when the NODE_ENV environment variable is set to production), npm will not install modules listed in devDependencies.

Why does npm install add a bunch of other packages?

I ran npm install grunt-contrib-uglify --save-dev to my local project folder and it kept adding a bunch of other node module packages. How do I make it only install the package specified?
NPM installes package dependencies recursively. So when you install grunt-contrib-uglify it will also install chalk, lodash, maxmin, uri-path and, uglify-js. It will also then install any dependencies those packages have. You can't install just grunt-contrib-uglify because it wouldn't work without them.

meteor requires npm install on each new machine

I just cloned my meteor github repo to a new machine and now I have to npm install some packages again. I thought that they are part of the meteor app once I have them installed. (and I checked. they are in the node_modules folder and listed in the packages.json). Nonetheless, I get the error:
Can't find npm module 'react'. Did you forget to call 'Npm.depends' in package.js witin the 'modules-runtime'package?
I am running meteor 1.3.1

How to uninstall npm package?

I've installed grunt using sudo npm install grunt and now I can't remove it.
I've tried:
$ sudo npm uninstall grunt
But it gives me a WARN:
npm WARN uninstall not installed in /home/kuba/projects/node_modules: "grunt-cli"
I've also tried rm, remove and unlink. and -g options, but those give:
npm WARN uninstall not installed in /usr/lib/node_modules: "grunt"
But I still can run grunt from command line.
EDIT:
$ whereis grunt
grunt: /usr/local/bin/grunt
$ file /usr/local/bin/grunt
/usr/local/bin/grunt: symbolic link to `../lib/node_modules/grunt/bin/grunt'
$ ls /usr/local/lib/node_modules
grunt jshint
$ ls /usr/lib/node_modules
bower csslint devtools-terminal npm plato
Why I have 2 directories with npm? Is it safe to just delete them?
EDITOR NOTE:
This question was asked over 5 years ago as How to uninstall npm package. It's been a very useful question favourited by many, who found a solution to their problem, so I'm changing it back from a recent edit that called it How to uninstall grunt package, because it requires the same procedure as any other npm package.
To uninstall a npm module from project node_modules folder, run:
npm uninstall <module> --save
Note that npm modules should be uninstalled from the same directory that contains the node_modules folder when running this command. The --save option will also remove it from your package.json
One can also remove a local dependency/module installation, by deleting its directory from the local node_modules folder. Yes, it's safe to delete dependencies there.
To uninstall a npm module that was installed globally, run:
npm uninstall -g <module>
It doesn't matter where you run this command from.
To install a npm module, run: (only meant as reference)
npm install <module>
...or:
npm install (if there's a package.json file at the root of your project)
...or:
npm install <module> --save-dev (if you want to add a minimum version to the dependency)
Good things to know about Grunt:
If you have installed grunt stable before February 18, 2013 (the day grunt v0.4.x was released), you might have an older grunt version still lingering in your system. That's because grunt versions lower than 0.4.x were installed globally, which caused a lot of pain when upgrading/maintaining versions.
grunt and grunt-cli are two different things.
grunt (without the "cli") is usually installed at the project level (when listed as a devDependency in package.json) by running npm install. That's also known as a local installation.
grunt-cli is the underlying foundation on which local versions of grunt run in different projects/folders. It can be installed locally, but is more useful when installed globally, once.
grunt is only installed locally (by running npm install grunt).
grunt-cli is preferably installed globally (by running npm install -g grunt-cli). grunt-cli official npm page still warns against installing grunt (without the cli) globally.
If you want to uninstall the global installation of grunt-cli, run npm uninstall -g grunt-cli. This issue on gruntjs's project supports this procedure.
Never install grunt globally (by running npm install -g grunt).
On npm and sudo
sudo doesn't play well with npm. Only use it if you must. Below are two quotes on the advantages and disadvantages on its use:
Quoting Isaac Z. Schlueter on his Introduction to npm article:
I strongly encourage you not to do package management with sudo!
Packages can run arbitrary scripts, which makes sudoing a package manager command
as safe as a chainsaw haircut. Sure, it's fast and definitely going to cut
through any obstacles, but you might actually want that obstacle to stay there.
I recommend doing this once instead:
sudo chown -R $USER /usr/local
That sets your user account as the owner of the /usr/local directory, so that you can
just issue normal commands in there. Then you won't ever have to use sudo when you
install node or issue npm commands.
It's much better this way. /usr/local is supposed to be the stuff you installed, after all.
Yet another catch mentioned by Andrei Karpushonak:
There are certain security concerns and functionality limitations
regarding changing the ownership of /usr/local to the current user:
if there is another user on the machine who could use global
npm packages - do not change the ownership of /usr/local
https://apple.stackexchange.com/questions/1393/are-my-permissions-for-usr-local-correct
https://askubuntu.com/questions/261326/is-it-safe-to-chown-usr-local
Having said that, if you want to install global module without using sudo,
I don't see any better solution (from pragmatic point of view) than mentioned.
Security vs easy of use is very broad topic, and there is no easy answer for that
- it just depends on your requirements.
This same thing happened with me. On doing
which grunt
I got path /usr/local/bin/. There was a folder grunt inside this.
But on running command (even from within the path /usr/local/bin/):
sudo npm uninstall -g grunt
Got the warning uninstall not installed
Solution: turns out that I installed using command
sudo npm install -g grunt-cli
And while trying to remove was just typing grunt.
So once I run
sudo npm uninstall -g grunt-cli
grunt got removed.
Although you have mention in question that you run
sudo npm install grunt
But still check if you are also doing the same mistake and run it with grunt-cli.
In some cases it may be necessary to use npm's "remove a package," feature.
npm - Remove a package
Description
"This uninstalls a package, completely removing everything npm installed on its behalf."
On your third code block, you posted this message:
npm WARN uninstall not installed in /home/kuba/projects/node_modules: "grunt-cli"
I've found that using the
which grunt
or the
whereis grunt
commands in the CLI/console provides an incomplete and confusing output.
Both of these commands will return the path of the grunt-cli installation, but return this simply as grunt.
Also using,
which grunt-cli
or the
whereis grunt-cli
fails to return any output to the CLI console. I believe that this is a namespace issue/feature with npm.
I also had a situation where I was unable to uninstall the grunt-cli with npm's uninstall function as recommended by other contributors above.
The only thing that worked for me was using the npm remove function with the program's full name as demonstrated below.
npm rm -g grunt-cli
This should return the following to your console.
unbuild grunt-cli##.##.#
Good Luck!
Use first this one
which grunt-cli
Or
which grunt
And this will show you the path to the module
In my case it was in the /usr/local/bin/
Once I got into the bin folder I just wrote
sudo rm grunt
And that was the end of it :)
If it's installed globally add -g to uninstall and probably you will need sudo
sudo npm uninstall -g grunt
Running the accepted solution's commands didn't work for me. Running which grunt would result in /usr/local/bin/grunt, but normal (or sudo) npm uninstall -g grunt-cli had no effect.
This is the command that finally worked for me:
sudo npm uninstall grunt-cli -g --prefix=/usr/local
Thanks to gengxuelei on github for the solution!

Resources