-
-
Save yogain123/c4516979c00dae9b01bbdfd1ecb3ba2c to your computer and use it in GitHub Desktop.
hola |
Command
npm install lodash --save
npm update lodash --save
npm uninstall lodash --save
npm install
npm update
npm install nodemon -g
npm update -g // update all global dependencies
npm list
npm cache clean --force
To remove package which are present in local but not present in package.json
npm prune
Scripts
"scripts":{
"start":"node index.js"
"hola":"nodemon"
}
npm start
npm run hola // running custom script
Running Backend and Frontend in Same Server (Express)
Usually scripts run the root of package.json , to add prefix , to say run it on some other dir , so here running inside client
`"client":"npm run start --prefix client"
Running both FE and BE together with one command , write a script
"dev":"concurrently \"npm run server\" \"npm run client\""
prettier
npm install prettier -g
prettier --write *.js
prettier --write *.ts
prettier --write src/**/*.ts
get list of global npm package
npm list -g --depth 0
- npm install -g something
- npm install something --save
- npm start
- npm start targetFile
- npm run build
- npm run build --prod
- yarn install
- yarn add lodash --save
yarn doesn't install global dependecies
NVM
Download NVM from github
- nvm install 8.9.9
- nvm list
- nvm use 8.9.9
- nvm alias default 8.9.4
npx
node package executable
execute local installed things without writing down it in script
, if json-server is installed locally , then you can run
npx json-server -p 1234 -w db.json
extra
vendor.js
WebPack bundles all the file and babel convert ES6 from that bundles files to old version which all browser can understand
local dependencies ==> okay
global dependencies ==> okay
but if you want to run global dependencies installed locally, then you need to write script and run, otherwise it won't work
example::
npm install json-server -g // now running json-server from anywhere will work properly
BUT
npm install json-server --save // now running json-server will not work in project folder . thats why put it in script
"scripts":{
"executeMe":"json-server"
}
then ==> npm run executeMe
check module info
npm info <module-name>
npm info lodash
more npm command
pnpm -> check it for monorepo
npm link
npm pack
npm ls <package-name>
--> print to stdout all the versions of a package that is installed, including their dependencies in a tree-structure
Versioning
"lodash":"^4.12.11"
it means leave the major version , but get lastest stable minor and patch version when doing npm install
"lodash":"~4.12.11"
it means leave the major and minor version , but get lastest stable patch version when doing npm install
"lodash":"*"
get latest stable version of lodash