1

我将 VSTS 用作 NPM 私有仓库,但如果我想做 npm publish,总是希望发布到我的私有仓库,而不是发布到 npm 公共仓库。我已经安装

npm install -g vsts-npm-auth --registry https://registry.npmjs.com --always-auth false

比我这样做:

vsts-npm-auth -config .npmrc

我的 .npmrc 文件包含这个

registry=https://myhost/_packaging/myfeed/npm/registry/
always-auth=true

我也用过

"publishConfig": {
    "registry": "https://myhost/_packaging/myfeed/npm/registry/"
  },

覆盖注册表但没有成功。它总是想发布到 npm repo

npm ERR! Windows_NT 10.0.14393
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "publish"
npm ERR! node v7.7.3
npm ERR! npm  v4.1.2
npm ERR! code ENEEDAUTH

npm ERR! need auth auth required for publishing
npm ERR! need auth You need to authorize this machine using `npm adduser`

0 info it worked if it ends with ok
1 verbose cli [ 'C:\\Program Files\\nodejs\\node.exe',
1 verbose cli   'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli   'publish' ]
2 info using npm@4.1.2
3 info using node@v7.7.3
4 verbose publish [ '.' ]
5 silly cache add args [ '.', null ]
6 verbose cache add spec .
7 silly cache add parsed spec Result {
7 silly cache add   raw: '.',
7 silly cache add   scope: null,
7 silly cache add   escapedName: null,
7 silly cache add   name: null,
7 silly cache add   rawSpec: '.',
7 silly cache add   spec: 'C:\\temp\\empty-list',
7 silly cache add   type: 'directory' }
8 verbose addLocalDirectory C:\Users\cpi\AppData\Roaming\npm-cache\@systems\empty-list\1.0.0\package.tgz not in flight; packing
9 verbose correctMkdir C:\Users\cpi\AppData\Roaming\npm-cache correctMkdir not in flight; initializing
10 warn prepublish-on-install As of npm@5, `prepublish` scripts will run only for `npm publish`.
11 warn prepublish-on-install (In npm@4 and previous versions, it also runs for `npm install`.)
12 warn prepublish-on-install See the deprecation note in `npm help scripts` for more information.
13 info lifecycle @systems/empty-list@1.0.0~prepublish: @systems/empty-list@1.0.0
14 verbose lifecycle @systems/empty-list@1.0.0~prepublish: unsafe-perm in lifecycle true
15 verbose lifecycle @systems/empty-list@1.0.0~prepublish: PATH: C:\Program Files\nodejs\node_modules\npm\bin\node-gyp-bin;C:\temp\empty-list\node_modules\.bin;C:\Program Files\ConEmu\ConEmu\Scripts;C:\Program Files\ConEmu;C:\Program Files\ConEmu\ConEmu;C:\Program Files\Java\jdk1.8.0_121\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\Microsoft SQL Server\130\Tools\Binn\;C:\Program Files (x86)\Microsoft Emulator Manager\1.0\;C:\Program Files\nodejs\;C:\Program Files (x86)\Skype\Phone\;C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\110\Tools\Binn\;C:\Program Files (x86)\Microsoft SQL Server\120\Tools\Binn\;C:\Program Files\Microsoft SQL Server\120\Tools\Binn\;C:\Program Files\Microsoft SQL Server\120\DTS\Binn\;C:\Program Files (x86)\Microsoft SQL Server\120\Tools\Binn\ManagementStudio\;C:\Program Files (x86)\Microsoft SQL Server\120\DTS\Binn\;C:\Program Files\dotnet\;C:\Program Files\Microsoft\Web Platform Installer\;C:\Program Files (x86)\Microsoft SQL Server\Client SDK\ODBC\130\Tools\Binn\;C:\Program Files (x86)\Microsoft SQL Server\140\Tools\Binn\;C:\Program Files (x86)\Microsoft SQL Server\140\DTS\Binn\;C:\Program Files (x86)\Microsoft SQL Server\140\Tools\Binn\ManagementStudio\;C:\Program Files\Git\cmd;C:\Users\cpi\AppData\Local\Microsoft\WindowsApps;C:\Users\cpi\AppData\Roaming\npm;C:\Program Files\Microsoft VS Code Insiders\bin
16 verbose lifecycle @systems/empty-list@1.0.0~prepublish: CWD: C:\temp\empty-list
17 silly lifecycle @systems/empty-list@1.0.0~prepublish: Args: [ '/d /s /c', 'ngc && npm run build' ]
18 silly lifecycle @systems/empty-list@1.0.0~prepublish: Returned: code: 0  signal: null
19 info lifecycle @systems/empty-list@1.0.0~prepare: @systems/empty-list@1.0.0
20 silly lifecycle @systems/empty-list@1.0.0~prepare: no script for prepare, continuing
21 verbose tar pack [ 'C:\\Users\\cpi\\AppData\\Roaming\\npm-cache\\@systems\\empty-list\\1.0.0\\package.tgz',
21 verbose tar pack   'C:\\temp\\empty-list' ]
22 verbose tarball C:\Users\cpi\AppData\Roaming\npm-cache\@systems\empty-list\1.0.0\package.tgz
23 verbose folder C:\temp\empty-list
24 verbose addLocalTarball adding from inside cache C:\Users\cpi\AppData\Roaming\npm-cache\@systems\empty-list\1.0.0\package.tgz
25 verbose correctMkdir C:\Users\cpi\AppData\Roaming\npm-cache correctMkdir not in flight; initializing
26 silly cache afterAdd @systems/empty-list@1.0.0
27 verbose afterAdd C:\Users\cpi\AppData\Roaming\npm-cache\@systems\empty-list\1.0.0\package\package.json not in flight; writing
28 verbose correctMkdir C:\Users\cpi\AppData\Roaming\npm-cache correctMkdir not in flight; initializing
29 verbose afterAdd C:\Users\cpi\AppData\Roaming\npm-cache\@systems\empty-list\1.0.0\package\package.json written
30 silly publish { name: '@systems/empty-list',
30 silly publish   version: '1.0.0',
30 silly publish   description: 'An empty list',
30 silly publish   scripts:
30 silly publish    { clean: 'rimraf bundles coverage src/**/*.d.ts src/**/*.metadata.json src/**/*.js tests/**/*.d.ts tests/**/*.metadata.json tests/**/*.js index.d.ts index.metadata.json index.js',
30 silly publish      test: 'karma start',
30 silly publish      'test-watch': 'karma start --singleRun=false --autoWatch=true',
30 silly publish      prepublish: 'ngc && npm run build',
30 silly publish      build: 'webpack',
30 silly publish      'semantic-release': 'semantic-release pre && npm publish && semantic-release post' },
30 silly publish   repository:
30 silly publish    { type: 'git',
30 silly publish      url: 'git+https://github.com/systems/empty-list.git' },
30 silly publish   keywords: [ 'angular', 'angular 2', 'i18n', 'translate', 'ngx-translate' ],
30 silly publish   publishConfig: { registry: 'https://systems.pkgs.visualstudio.com/_packaging/Systems.Test-Packages/npm/registry/' },
30 silly publish   author: { name: 'Martin Pfeifhofer' },
30 silly publish   license: 'MIT',
30 silly publish   bugs: { url: 'https://github.com/systems/empty-list/issues' },
30 silly publish   homepage: 'https://github.com/systems/empty-list#readme',
30 silly publish   main: 'bundles/empty-list.umd.js',
30 silly publish   module: 'index.js',
30 silly publish   typings: 'index.d.ts',
30 silly publish   peerDependencies:
30 silly publish    { '@ngx-translate/core': '>=6.0.0',
30 silly publish      '@angular/core': '>=4.3.0',
30 silly publish      '@angular/common': '>=4.3.0' },
30 silly publish   devDependencies:
30 silly publish    { '@angular/animations': '4.3.1',
30 silly publish      '@angular/common': '4.3.1',
30 silly publish      '@angular/compiler': '4.3.1',
30 silly publish      '@angular/compiler-cli': '4.3.1',
30 silly publish      '@angular/core': '4.3.1',
30 silly publish      '@angular/platform-browser': '4.3.1',
30 silly publish      '@angular/platform-browser-dynamic': '4.3.1',
30 silly publish      '@angular/platform-server': '4.3.1',
30 silly publish      '@ngx-translate/core': '^7.0.0',
30 silly publish      '@types/hammerjs': '2.0.34',
30 silly publish      '@types/jasmine': '2.5.51',
30 silly publish      '@types/node': '7.0.28',
30 silly publish      'awesome-typescript-loader': '3.1.3',
30 silly publish      'clean-webpack-plugin': '0.1.16',
30 silly publish      codelyzer: '3.0.1',
30 silly publish      commitizen: '2.9.6',
30 silly publish      'core-js': '2.4.1',
30 silly publish      'cz-conventional-changelog': '2.0.0',
30 silly publish      'istanbul-instrumenter-loader': '2.0.0',
30 silly publish      'jasmine-core': '2.6.2',
30 silly publish      karma: '1.7.0',
30 silly publish      'karma-chrome-launcher': '2.1.1',
30 silly publish      'karma-coverage': '1.1.1',
30 silly publish      'karma-jasmine': '1.1.0',
30 silly publish      'karma-mocha-reporter': '2.2.3',
30 silly publish      'karma-remap-coverage': '0.1.4',
30 silly publish      'karma-sourcemap-loader': '0.3.7',
30 silly publish      'karma-webpack': '2.0.3',
30 silly publish      'loader-utils': '1.1.0',
30 silly publish      'reflect-metadata': '0.1.10',
30 silly publish      rimraf: '2.6.1',
30 silly publish      rxjs: '5.4.0',
30 silly publish      'semantic-release': '6.3.6',
30 silly publish      'source-map-loader': '0.2.1',
30 silly publish      'ts-helpers': '1.1.2',
30 silly publish      tslint: '5.4.3',
30 silly publish      'tslint-loader': '3.5.3',
30 silly publish      typescript: '2.3.4',
30 silly publish      webpack: '3.0.0-rc.1',
30 silly publish      'zone.js': '0.8.11' },
30 silly publish   config: { commitizen: { path: './node_modules/cz-conventional-changelog' } },
30 silly publish   dependencies: { '@ngx-translate/http-loader': '^1.0.2' },
30 silly publish   readme: '',
30 silly publish   readmeFilename: 'README.md',
30 silly publish   gitHead: '1d90b2d0696dc11ae80de565cd09d432db693b98',
30 silly publish   _id: '@systems/empty-list@1.0.0',
30 silly publish   _shasum: 'fbb07f54e36cbd754375bffebaab79d9903f7c60',
30 silly publish   _from: '.' }
31 info lifecycle @systems/empty-list@1.0.0~prepublishOnly: @systems/empty-list@1.0.0
32 silly lifecycle @systems/empty-list@1.0.0~prepublishOnly: no script for prepublishOnly, continuing
33 verbose getPublishConfig { registry: 'https://xxx.pkgs.visualstudio.com/_packaging/Systems.Test-Packages/npm/registry/' }
34 silly mapToRegistry name @systems/empty-list
35 silly mapToRegistry scope (from package name) @systems
36 verbose mapToRegistry no registry URL found in name for scope @systems
37 silly mapToRegistry using default registry
38 silly mapToRegistry registry https://xxx.pkgs.visualstudio.com/_packaging/Systems.Test-Packages/npm/registry/
39 silly mapToRegistry data Result {
39 silly mapToRegistry   raw: '@systems/empty-list',
39 silly mapToRegistry   scope: '@systems',
39 silly mapToRegistry   escapedName: '@systems%2fempty-list',
39 silly mapToRegistry   name: '@systems/empty-list',
39 silly mapToRegistry   rawSpec: '',
39 silly mapToRegistry   spec: 'latest',
39 silly mapToRegistry   type: 'tag' }
40 silly mapToRegistry uri https://xxx.pkgs.visualstudio.com/_packaging/Systems.Test-Packages/npm/registry/@systems%2fempty-list
41 verbose publish registryBase https://xxx.pkgs.visualstudio.com/_packaging/Systems.Test-Packages/npm/registry/
42 silly publish uploading C:\Users\cpi\AppData\Roaming\npm-cache\@systems\empty-list\1.0.0\package.tgz
43 verbose stack Error: auth required for publishing
43 verbose stack     at CachingRegistryClient.publish (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-registry-client\lib\publish.js:30:14)
43 verbose stack     at C:\Program Files\nodejs\node_modules\npm\lib\publish.js:137:14
43 verbose stack     at mapToRegistry (C:\Program Files\nodejs\node_modules\npm\lib\utils\map-to-registry.js:62:3)
43 verbose stack     at publish_ (C:\Program Files\nodejs\node_modules\npm\lib\publish.js:108:3)
43 verbose stack     at Array.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\slide\lib\bind-actor.js:15:8)
43 verbose stack     at LOOP (C:\Program Files\nodejs\node_modules\npm\node_modules\slide\lib\chain.js:15:14)
43 verbose stack     at C:\Program Files\nodejs\node_modules\npm\node_modules\slide\lib\chain.js:18:7
43 verbose stack     at done (C:\Program Files\nodejs\node_modules\npm\lib\utils\lifecycle.js:132:5)
43 verbose stack     at LOOP (C:\Program Files\nodejs\node_modules\npm\node_modules\slide\lib\chain.js:7:26)
43 verbose stack     at C:\Program Files\nodejs\node_modules\npm\node_modules\slide\lib\chain.js:18:7
44 verbose cwd C:\temp\empty-list
45 error Windows_NT 10.0.14393
46 error argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "publish"
47 error node v7.7.3
48 error npm  v4.1.2
49 error code ENEEDAUTH
50 error need auth auth required for publishing
51 error need auth You need to authorize this machine using `npm adduser`
52 verbose exit [ 1, true ]

更新:MyHome/.npmrc

//systems.pkgs.visualstudio.com/_packaging/Systems.Angular-Packages/npm/registry/:_authToken=xxxx
4

1 回答 1

1

好的,清除我的主文件夹中的 .npmrc 文件并重新运行 vsts-npm-auth -config .npmrc 文件夹可以解决问题。感谢@starain-MSFT 的提示。

于 2017-08-28T07:18:25.560 回答