npm
comes with Node.js. If you have Node installed, you have npm installed. You can check if it’s already installed with
1node -v
2npm -v
1# Install on Ubuntu Debian
2sudo apt update && sudo apt install nodejs npm -y
1npm init
inside your project folder. will create package.json
1npm i -S jquery
2npm i -D react react-dom
i
is short for install
--save
or -S
adds it to package.json as a dependency--save-dev
or -D
adds it as a dev dependency.-S
or -D
, jQuery would have been installed into our node_modules/ folder but not saved to the package.json file.if you were collaborating with a teammate, instead of having to push your entire node_modules
folder to github, your teammate can just clone your project and run npm install
and all of your dependencies that are saved inside of your package.json
file (in this case just jquery) will be downloaded to her node_modules
folder.
let’s you run commands you saved under scripts
in package.json.
Inside of your package.json file, under the "scripts"
property, add
1"test": "ava 'app/**/*.test.js' --verbose --require ./other/setup-ava-tests.js"
so that your complete scripts sections looks like
1 "scripts": {
2 "test": "ava 'app/**/*.test.js' --verbose --require ./other/setup-ava-tests.js"
3 }