Im a bit confused. On my laptop, as I built up my project, my package.json
got populated with dependencies as I installed them.
It looks like this:
"main": "webpack.config.js",
"dependencies": {
"immutable": "^3.7.6",
"react": "^0.14.8",
"react-dom": "^0.14.8",
"react-redux": "^4.4.2",
"redux": "^3.4.0"
},
"devDependencies": {
"babel-core": "^6.7.6",
"babel-loader": "^6.2.4",
"babel-polyfill": "^6.7.4",
"babel-preset-es2015": "^6.6.0",
"babel-preset-react": "^6.5.0",
"babel-preset-react-hmre": "^1.1.1",
"css-loader": "^0.23.1",
"eslint": "^2.7.0",
"eslint-loader": "^1.3.0",
"eslint-plugin-react": "^4.3.0",
"postcss-loader": "^0.8.2",
"style-loader": "^0.13.0",
"stylelint": "^4.5.1",
"webpack": "^1.12.15",
"webpack-dev-server": "^1.14.1",
"webpack-merge": "^0.7.3"
},
Now, on my new system, pulled the repo & was under the impression that all I have to call is npm install
& npm would read package.json & download all the dependencies and their specified versions. That didnt happen.
So, my question is, how do we correctly, install all of these dependencies onto a new system.
Would it be a matter of running npm i --save [all the dependencies]
& npm i --save-dev [all the dev dependencies]
Also, how would the version number be resolved if I do the above? I mean, package.json has the versions specified while running the above two mands would download the latest versions of each package.
Many thanks,
Im a bit confused. On my laptop, as I built up my project, my package.json
got populated with dependencies as I installed them.
It looks like this:
"main": "webpack.config.js",
"dependencies": {
"immutable": "^3.7.6",
"react": "^0.14.8",
"react-dom": "^0.14.8",
"react-redux": "^4.4.2",
"redux": "^3.4.0"
},
"devDependencies": {
"babel-core": "^6.7.6",
"babel-loader": "^6.2.4",
"babel-polyfill": "^6.7.4",
"babel-preset-es2015": "^6.6.0",
"babel-preset-react": "^6.5.0",
"babel-preset-react-hmre": "^1.1.1",
"css-loader": "^0.23.1",
"eslint": "^2.7.0",
"eslint-loader": "^1.3.0",
"eslint-plugin-react": "^4.3.0",
"postcss-loader": "^0.8.2",
"style-loader": "^0.13.0",
"stylelint": "^4.5.1",
"webpack": "^1.12.15",
"webpack-dev-server": "^1.14.1",
"webpack-merge": "^0.7.3"
},
Now, on my new system, pulled the repo & was under the impression that all I have to call is npm install
& npm would read package.json & download all the dependencies and their specified versions. That didnt happen.
So, my question is, how do we correctly, install all of these dependencies onto a new system.
Would it be a matter of running npm i --save [all the dependencies]
& npm i --save-dev [all the dev dependencies]
Also, how would the version number be resolved if I do the above? I mean, package.json has the versions specified while running the above two mands would download the latest versions of each package.
Many thanks,
Share Improve this question asked Apr 11, 2016 at 21:30 KayoteKayote 15.7k26 gold badges96 silver badges152 bronze badges 02 Answers
Reset to default 5If you want to install the latest module versions meet the version requirements, you should use the mand:
npm i
In that case, for immutable
module, for example, will be installed the latest 3.x version.
But if you want to install the same versions as on your first development pc, you need too do the following:
npm shrinkwrap # run this mand on first pc
npm i # run this mand on a new pc
All you have to call is npm install, it will download the most recent major versions (^ caret range syntax) listed in dependencies and devDependencies
https://docs.npmjs./cli/install
To install a specific version, remove the caret e.g.
"react": "0.14.8",
You can use 'npm shrinkwrap' to lock down the versions of a package's dependencies -- creates a file npm-shrinkwrap.json containing the exact package versions in the entire hierarchy
https://docs.npmjs./cli/shrinkwrap
package.json interactive guide http://browsenpm/package.json