Npm Install Version Syntax
Npm install [email protected] npm install @myorg/[email protected] npm install [/]@: Install a version of the package matching the specified version range. Those of you upgrading npm to its latest version, npm@5.2.0, might notice that it installs a new binary alongside the usual npm: npx. If you need to install or update Node.js and npm on your OS, we recommend that you install Node.js LTS version 4.x or later. If you use an older version, you might get installation errors. 01 - Try the latest stable version of node 02 - Try the latest stable version of npm 03 - If your npm is broken 04 - Try clearing the npm cache 05 - Common Errors Using npm coding-style config developers disputes orgs registry removing-npm scope scripts semver. The easiest way to install npm packages is through the npm package installation window. To access this window, right-click the npm node in the project and select Install New npm Packages. In this window you can search for a package, specify options, and install.
- Npm Install Particular Version
- Npm Version String
- Npm Dev Dependencies
- Npm Install Version Syntax
- Npm Version Syntax
- Npm Install Version Syntax
I used nvm to download node v0.4.10 and installed npm to work with that version of node.
I am trying to install express using
and I get an error that express requires node version >= 0.5.0.
Well, this is odd, since I am following the directions for a node+express+mongodb tutorial here that used node v0.4.10, so I am assuming express is/was available to node v0.4.10. If my assumption is correct, how do I tell npm to fetch a version that would work with my setup?
Alexander Abakumov9 Answers
If you have to install an older version of a package, just specify it
For example: npm install express@3.0.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:
And npm view
can be used for viewing other things about a package too. https://docs.npmjs.com/cli/view
First remove old version, then run literally the following:
and for stable or recent
Saurabh Chandra PatelSaurabh Chandra PatelIn my opinion that is easiest and fastest way:
$ npm -v
4.2.0
$ npm install -g npm@latest-3
..
Npm Install Particular Version
$ npm -v
Npm Version String
3.10.10
you can update your npm package by using this command:
npm install <package_name>@<version_number>
example:npm install yargs@12.02
You can use the following command to install a previous version of an npm package:
Grant MillerI have a general way to solve this type of problems, which could be helpful too, especially when cloning repositories to run them locally, but requires a little more analysis of the versions.
With the package npm-check-updates
I verify the versions of the packages (according to the package.json file) that are not declared in their latest available versions, as shown in the figure (https://www.npmjs.com/package/npm-check-updates):
With this information we can verify the update status of the different packages and make decisions as to which packages to upgrade / degrade and which ones do not.
Assuming that we decided to update all the packages as they are listed, we can use the ncu -u
command which only modifies your package.json file. Run npm install
to update your installed packages and package-lock.json.
Then, depending on the requirements of the repository, we can refine what is needed, installing the specific versions with npm view <package> versions
and npm install <package>@<version>
npm install -g npm@version
in which you want to downgrade
npm install -g npm@3.10.10
On Ubuntu you can try this command.
Specific version : sudo n 8.11.3 instead of sudo n stable
Not the answer you're looking for? Browse other questions tagged node.jsnpm or ask your own question.
Say you want to install a library lib-a
which has dependencies dep-1
and dep-2
. If lib-a
has declared in its package.json to use a version of dep-2
that is out of date (say it doesn't work on node 0.8.0 which just came out), but there is a branch of dep-2
that works with node 0.8.0 - branch name node0.8.0
.
So the packages in the equation are:
Cva serial number lookup. Is there a way to tell NPM to install lib-a
, but use dep-2#node0.8.0
instead of dep-2
?
With NPM you can install a specific branch of a project like this:
And if I were to customize the package.json of lib-a
, you could tell it to use dep-2#node0.8.0
like this:
By modifying the package.json you can then run
and it will install the node 0.8.0 compatible dep-2
branch. But, that requires I have access to modifying lib-a
, which for my specific case I don't. Technically, I could fork lib-a
and make the above change to package.json. But in my specific case, lib-a
is a dependency of another library, so I'd have to fork the project it's referenced in, and on and on..
So the question is, is there a way to tell NPM to install lib-a
, and tell it to use the node0.8.0
branch of dep-2
? Something like this:
That would be awesome. If it's not possible, that would be good to know so I can prepare myself to have to fork/customize the chain of projects.
1 Answer
NPM install syntax:
Npm Dev Dependencies
so you can choose one of these methods to install your modules.
The case of the simplest way to install a specific version is this one:
Npm Install Version Syntax
more info:https://docs.npmjs.com/cli/install
micnicmicnic