我已经创建了一个公共的npm存储库:https://www.npmjs.com/package/point-cloud-visualiser
我正在尝试从codebuild中运行npm publish
。我已经生成了一个令牌并将其保存在AWS secrets manager中。我成功地将secret拉入buildspec中。但是我不确定如何配置.npmrc文件,使其使用令牌,并且不告诉我登录。
当前我的.npmrc如下所示:
@point-cloud-visualiser:registry=https://www.npmjs.com/package/point-cloud-visualiser
//point-cloud-visualiser/:_authToken=${NPM_TOKEN}
我的buildspec.yml看起来像这样:
version: 0.2
env:
secrets-manager:
NPM_TOKEN: "npm-token:npm-token"
phases:
install:
commands:
- npm install
build:
commands:
- npm run build
- npm publish
但是,当它在npm publish
上失败时,会出现以下错误:
npm ERR! code ENEEDAUTH
npm ERR! need auth This command requires you to be logged in to https://registry.npmjs.org/
npm ERR! need auth You need to authorize this machine using `npm adduser`
我还尝试删除.npmrc文件并在buildspec.yml中使用以下代码:
version: 0.2
env:
secrets-manager:
NPM_TOKEN: "npm-token:npm-token"
phases:
install:
commands:
- npm install
build:
commands:
- npm run build
- npm config set registry 'https://www.npmjs.com/package/point-cloud-visualiser'
- npm config set '//npmjs.com/package/point-cloud-visualiser/:always-auth' 'true'
- npm config set '//npmjs.com/package/point-cloud-visualiser/:_authToken' '${NPM_TOKEN}'
- npm publish
但是这种方法给出了和上面一样的结果。我做错了什么?谢谢!
1条答案
按热度按时间3xiyfsfu1#
以下构建规范已成功运行: