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.
# 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)
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