DAILY DOCDAILY DOC
Rust
Node
Notes
Ubuntu
Leetcode
  • it-tools
  • excalidraw
  • linux-command
Rust
Node
Notes
Ubuntu
Leetcode
  • it-tools
  • excalidraw
  • linux-command
  • BFC 块级格式化上下文
  • Note
  • WebAssembly
  • public api
  • 位运算
  • bitwise operator
  • css实现隐藏效果
  • css snippets
  • 抖音点赞
  • js 相等判断
  • fetch ReadableStream
  • git
  • Github Actions 工作流
  • google search
  • RPC vs HTTP
  • gravatar
  • hhkb
  • Init project
  • input 文件上传
  • mac

    • Mac 使用技巧
    • alfred
    • mac shortcuts
    • shortcuts text edit
    • mac 修改host
  • 微前端
  • mock
  • nginx dump
  • nginx
  • NirCmd
  • npm
  • Operator Precedence
  • package.json
  • url query 解析
  • pnpm
  • JavaScript Precise countdown
  • react 模版
  • regexp
  • setup web development
  • telegram

    • telegram bot
  • timeFunction ease
  • 视频裁剪
  • vscode

    • vscode 高级指南
    • bracketPairs
    • jsconfig.json
    • vscode pipe into code
    • social project
    • vscode tasks
  • draggable resizable
  • windows 激活
  • 前端截图实现
  • 文本配音 富文本实现
  • 图片处理
  • 前端坐标
  • 定时任务
  • work efficient
  • 微信小程序动画实现方案
  • 排列组合
  • 数列
  • 语音驱动文字
  • 浏览器
  • 状态管理
  • 移动盒子
  • 移动端开发常用snippets
  • 设计模式
  • web performance

npm

npm docs <pkg> # open the docs of pkg
npm repo <pkg> # open the repository of pkg
npm run-script <command> [--if-present] [--silent] [-- <args>]

传参

--a=1

"scripts": {
  "test": "node app.js",  // 1
}
npm run test --a=1

> trader@1.0.0 test
> node app.js "1"

[
  'xxx',
  'xxx/app.js',
  '1' // process.argv[2]
]
undefined

-- --a=1

npm run test -- --a=1

> trader@1.0.0 test
> node app.js "--a=1"

[
  'xxx',
  'xxx/app.js',
  '--a=1'
]

npm 配置 github registry

编辑 ~/.npmrc

//npm.pkg.github.com/:_authToken=xxxx  # xxx 为github personal access token

Refer

  • working-with-the-npm-registry

npm 安装 github private 包

details
#  Use default ssh account
npm i git@github.com:xxx/xxx.git

# # Or use another ssh account

# npm i git+ssh://xxxx:xx/xx.git

.npmrc

details

1. 全局配置 .npmrc 文件

如果你想为整个系统的 npm 配置创建一个全局 .npmrc 文件,可以通过以下命令进行操作:

npm config set <key> <value>

例如,你可以设置全局 registry(npm 的镜像源):

npm config set registry https://registry.npmjs.org/

这将会在你的用户目录下(如 ~/.npmrc)创建一个 .npmrc 文件。

2. 项目级 .npmrc 文件

如果你想为特定的项目创建 .npmrc 文件,直接在项目根目录下手动创建该文件,或者可以使用 npm config 命令为该项目添加特定的配置。

在项目根目录下运行以下命令:

npm config set <key> <value> --location=project

例如,为项目设置镜像源:

npm config set registry https://registry.npmjs.org/ --location=project

这将在你的项目根目录下生成或修改 .npmrc 文件。

3. 手动创建 .npmrc 文件

你也可以直接手动在项目目录下创建 .npmrc 文件,并根据需要添加配置,例如:

registry=https://registry.npmjs.org/
//registry.npmjs.org/:_authToken=<your-auth-token>

Refer

-how-to-use-npm-as-a-build-tool

Last Updated:
Contributors: rosendo
Prev
NirCmd
Next
Operator Precedence