NodeJS

From RHS Wiki
Jump to navigation Jump to search

Install Kali[edit]

sudo apt-key adv --keyserver hkp://keys.gnupg.net --recv-keys 1655A0AB68576280
sudo nano /etc/apt/sources.list.d/nodesource.list
deb https://deb.nodesource.com/node_12.x stretch main
deb-src https://deb.nodesource.com/node_12.x stretch main
sudo apt update
sudo apt install nodejs npm


NPM (Node package manager)[edit]

Create new project[edit]

npm init

Install package in project[edit]

npm install jquery

packages will be downloaded to node_modules folder

Install modules from existing project[edit]

npm install

Fix broken[edit]

npm cache clean --force
rm -rf node_modules
# rm package-lock.json  # If not updating packages
# npm install

package.json[edit]

~ only allows patch updates

^ only allows minor version update

* allows mayor version upgrades

"dependencies": {
    "@angular/animations": "^12.2.9",
    "@angular/cdk": "~12.2.9",
    "@angular/common": "*"
}

npm Behind Proxy[edit]

npm config set http-proxy http://user:pass@proxy.example.com:3128
npm config set https-proxy http://user:pass@proxy.example.com:3128

npm cli[edit]

npm view <packagename> versions --json
npm install jquery@"^1.9.0"