I've got a project where we're trying to get Node up and running across multiple developers' machines. The problem is that not all of the developers are Node (or even JavaScript) developers, and we want to ensure that they have the Node version necessary to run a specific project (developers will have multiple Node projects on their machines).
I read about package.json's "engines" field, but I couldn't seem to find any way to get the version of Node installed that I needed. To test, I set my current node version to v0.10.29 via NVM, created a package.json specifying a necessary engine of v0.11.13, and tried to start Node via the node command as well as via a package.json-defined npm start command.
blackjack:node-engines-test sent1nel$ node -v v0.10.29 blackjack:node-engines-test sent1nel$ cat package.json { "name": "node-engines-test", "version": "0.0.0", "description": "", "main": "index.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, "engineStrict": true, "engines": { "node": "v0.11.13" }, "start": "node index.js", "author": "", "license": "ISC" } blackjack:node-engines-test sent1nel$ cat index.js console.log('Version: ' + process.version); blackjack:node-engines-test sent1nel$ node index.js Version: v0.10.29 blackjack:node-engines-test sent1nel$ npm start blackjack:node-engines-test sent1nel$ npm install doesn't seem to care about the node engine version either.
blackjack:node-engines-test sent1nel$ npm install npm WARN package.json [email protected] No description npm WARN package.json [email protected] No repository field. npm WARN package.json [email protected] No README data blackjack:node-engines-test sent1nel$ node -v v0.10.29 What gives?!
enginesinstalls, requires or uses a specific Node version? I'm pretty sure all it does it provide information about what version of node is expected - npmjs.org/doc/package.json.html#engines . If you want to force a version (for whatever reason), you can useengineStrict- npmjs.org/doc/package.json.html#engineStrictpackage.json, I actually did set theengineStrictflag. What I'd assumed would happen was that setting that flag would either install or provide a warning that the wrong version of Node was active which, as you can see from the logs, doesn't happen.nvm- I simply want to ensure a warning is displayed so if the developer needs to runnvm install vx.y.z, they know what to do. If nothing exists, I have code to write.engineStrictflag if it's functionally useless?)