Skip to content

Instantly share code, notes, and snippets.

@yogain123
Last active May 2, 2022 13:20
Show Gist options
  • Save yogain123/c4516979c00dae9b01bbdfd1ecb3ba2c to your computer and use it in GitHub Desktop.
Save yogain123/c4516979c00dae9b01bbdfd1ecb3ba2c to your computer and use it in GitHub Desktop.
npm+webpack
@yogain123
Copy link
Author

get list of global npm package

npm list -g --depth 0

@yogain123
Copy link
Author

  • 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

@yogain123
Copy link
Author

NVM

Download NVM from github

  • nvm install 8.9.9
  • nvm list
  • nvm use 8.9.9
  • nvm alias default 8.9.4

@yogain123
Copy link
Author

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

@yogain123
Copy link
Author

Server Side Templating VS Single Page App

Screen Shot 1941-04-26 at 10 33 14 PM



Screen Shot 1941-04-26 at 10 33 27 PM



Screen Shot 1941-04-26 at 10 33 34 PM

@yogain123
Copy link
Author

Core Purpose of Javascript

Screen Shot 1941-04-26 at 10 45 56 PM

@yogain123
Copy link
Author

extra

vendor.js

Screen Shot 1941-04-27 at 12 11 40 AM



Screen Shot 1941-04-27 at 12 15 20 AM



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

@yogain123
Copy link
Author

yogain123 commented Apr 25, 2022

check module info

npm info <module-name>
npm info lodash

@yogain123
Copy link
Author

yogain123 commented Apr 26, 2022

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment