Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it ok to use npm 3.x with nodejs 4.x?

See title. I searched all across the internets and could not find a firm answer.

The reason I want to use npm3 is because I am working in a Windows environment and I am hitting the dreaded too long path name. Migrating off Windows is not a viable option at this time.

Also, I can not upgrade to node 5.x because I use the karma test runner, which is not yet supported on node 5.x

So, I want to use node 4.x with npm 3.x.

I have successfully updated my machine, using the slick npm-windows-upgrade package, to use npm 3 with node 4.

After the upgrade, I did see a couple issues with karma not realizing jasmine/phantomjs was available. The workaround was simply to install both those packages locally.

like image 593
Mr. Ant Avatar asked Dec 21 '15 21:12

Mr. Ant


People also ask

Is Node.js required for npm?

To publish and install packages to and from the public npm registry or a private npm registry, you must install Node. js and the npm command line interface using either a Node version manager or a Node installer.

Is npm and Node.js the same?

Node. js or Node is an open-source, cross-platform, JavaScript runtime environment(JSRE) that executes JavaScript code outside of a web browser. npm is a package manager(like Nuget package manager in . NET -Microsoft ) for the JavaScript programming language.

Does Node.js version matter?

​ LTS stands for Long Term Support and the recommended version for most users. Nodejs org makes new versions frequently with new features, bug fixes, and performance optimizations. As a general rule, we can safely assume that the latest version is always the best version to use.

Does npm 6 install peer dependencies?

With npm version 4 through to 6, a warning is issued when you run npm install to remind you to install the peer dependencies. Prior to version 4, npm automatically included peer dependencies if they weren't explicitly included.


1 Answers

Yes. The npm 3.x is compatible with node 4.x. In fact, any node >= 0.8 is okay.

This has been documented in https://www.npmjs.com/package/npm#important You need node v0.8 or higher to run this program.

And more, I suggest you to use the nvm https://github.com/creationix/nvm It very easy to switch in various node environments with nvm.

Your jasmine/phantomjs is references by peerDependencies, npm 2.x will install it if missing, and an error will be reported if found version conflict by multiple package.

As you known ,the npm 3.x flatten the package dependencies, peerDependencies will print a line of warn message only(will not be instal), you should manually include peerDependencies in your package.json file, this means it is you that decide which version should be installed.

like image 79
Bear Vast Avatar answered Oct 10 '22 02:10

Bear Vast