Using npm during the batch upload to cloudflare R2.
Introduction
npm is the package manager for the Node JavaScript platform. It puts modules in place so that node can find them, and manages dependency conflicts intelligently. It is extremely configurable to support a variety of use cases. Most commonly, you use it to publish, discover, install, and develop node programs.
What is Node
Node.js® is a JavaScript runtime built on Chrome’s V8 JavaScript engine.
Node.js is an open source server environment;
Node.js is free;
Node.js runs on various platforms (Windows, Linux, Unix, Mac OS X, etc.)
换源
1 2
# 淘宝源 npm config set registry https://registry.npmmirror.com
代理
优先换源
options
--save-dev [^3]
--save will install to node_modules folder in current dorectory.
E:/PowerShell via via 🐍 v3.9.7 ❯ $env:http_proxy = "http://127.0.0.1:7890"
E:/PowerShell via via 🐍 v3.9.7 ❯ nvm install 18.20.0 Downloading node.js version 18.20.0 (64-bit)... Extracting node and npm... Complete Installation complete. If you want to use this version, type:
nvm use 18.20.0
E:/PowerShell via via 🐍 v3.9.7 took 11s ❯ nvm use 18.20.0 Now using node v18.20.0 (64-bit)
Update Node.js with NPM
Using [^1]
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
# Install n, Node’s version manager: npm install -g n # Install the latest stable version: $ sudo n stable installing : node-v20.9.0 mkdir : /usr/local/n/versions/node/20.9.0 fetch : https://nodejs.org/dist/v20.9.0/node-v20.9.0-linux-x64.tar.xz copying : node/20.9.0 installed : v20.9.0 (with npm 10.1.0)
Note: the node command changed location and the old location may be remembered in your current shell. old : /usr/bin/node new : /usr/local/bin/node If "node --version" shows the old version then start a new shell, or reset the location hash with: hash -r (for bash, zsh, ash, dash, and ksh) rehash (for csh and tcsh)
# shaojiemike @ snode6 in ~ [17:03:56] C:127 $ npm ls shaojiemike@ /staff/shaojiemike ├── anichart@3.2.5 └── wrangler@3.15.0
npm install path / execute location
To install a public package, on the command line, run npm install <package_name>. This will create the node_modules directory in your current directory (if one doesn’t exist yet) and will download the package to that directory. (But not link to PATH)[^2]
1 2 3
# shaojiemike @ snode6 in ~ [17:51:17] $ l node_modules/wrangler/bin/wrangler.js -rwxr-xr-x 1 shaojiemike acsastaff 4.1K Nov 1 16:33 node_modules/wrangler/bin/wrangler.js
npx , Link it or Install global
npx <package_name> to execute local package.
npm install <package_name> -g will auto-link execute to usr/local/bin