範圍和儲存庫

# Set the repository for the scope "myscope"
npm config set @myscope:registry http://registry.corporation.com

# Login at a repository and associate it with the scope "myscope"
npm adduser --registry=http://registry.corporation.com --scope=@myscope

# Install a package "mylib" from the scope "myscope"
npm install @myscope/mylib

如果你自己的包的名稱以 @myscope 開頭,並且範圍 myscope 與不同的儲存庫相關聯,則 npm publish 會將你的包上傳到該儲存庫。

你還可以在 .npmrc 檔案中保留這些設定:

@myscope:registry=http://registry.corporation.com
//registry.corporation.com/:_authToken=xxxxxxxx-xxxx-xxxx-xxxxxxxxxxxxxxx

在 CI 伺服器 fe 上自動構建時,這非常有用