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
npm install express -g
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?
I 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. Runnpm 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
andnpm install <package>@<version>
You can use the following command to install a previous version of an npm package:
It's quite easy. Just write this, for example:
Or:
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/installIf 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/viewIn my opinion that is easiest and fastest way:
$ npm -v
4.2.0
$ npm install -g npm@latest-3
...
$ npm -v
3.10.10
First remove old version, then run literally the following:
and for stable or recent