数字资产分类帐项目的Node.js绑定

时间:2019-02-22 18:13:40

标签: node.js npm daml

我正在研究Digital Asset Getting Started with Node.js bindings

运行

npm install @da/daml-ledger

导致以下错误消息

npm ERR! code E401
npm ERR! 401 Unauthorized: @da/daml-ledger@latest

npm ERR! A complete log of this run can be found in:
npm ERR!     /...../.npm/_logs/2019-02-22T17_48_44_560Z-debug.log

以下是该日志文件的内容:

0 info it worked if it ends with ok
1 verbose cli [ '/usr/local/lib/nodejs/node-v10.15.1-linux-x64/bin/node',
1 verbose cli   '/usr/local/lib/nodejs/node-v10.15.1-linux-x64/bin/npm',
1 verbose cli   'install',
1 verbose cli   '@da/daml-ledger' ]
2 info using npm@6.4.1
3 info using node@v10.15.1
4 verbose npm-session 99e5e60df68735cb
5 silly install loadCurrentTree
6 silly install readLocalPackageData
7 http fetch GET 401 https://api.bintray.com/npm/digitalassetsdk/npm/@da%2fdaml-ledger 411ms
8 silly fetchPackageMetaData error for @da/daml-ledger@latest 401 Unauthorized: @da/daml-ledger@latest
9 timing stage:rollbackFailedOptional Completed in 4ms
10 timing stage:runTopLevelLifecycles Completed in 515ms
11 verbose stack Error: 401 Unauthorized: @da/daml-ledger@latest
11 verbose stack     at fetch.then.res (/usr/local/lib/nodejs/node-v10.15.1-linux-x64/lib/node_modules/npm/node_modules/pacote/lib/fetchers/registry/fetch.j
s:42:19)
11 verbose stack     at tryCatcher (/usr/local/lib/nodejs/node-v10.15.1-linux-x64/lib/node_modules/npm/node_modules/bluebird/js/release/util.js:16:23)
11 verbose stack     at Promise._settlePromiseFromHandler (/usr/local/lib/nodejs/node-v10.15.1-linux-x64/lib/node_modules/npm/node_modules/bluebird/js/relea
se/promise.js:512:31)
11 verbose stack     at Promise._settlePromise (/usr/local/lib/nodejs/node-v10.15.1-linux-x64/lib/node_modules/npm/node_modules/bluebird/js/release/promise.
js:569:18)
11 verbose stack     at Promise._settlePromise0 (/usr/local/lib/nodejs/node-v10.15.1-linux-x64/lib/node_modules/npm/node_modules/bluebird/js/release/promise
.js:614:10)
11 verbose stack     at Promise._settlePromises (/usr/local/lib/nodejs/node-v10.15.1-linux-x64/lib/node_modules/npm/node_modules/bluebird/js/release/promise
.js:693:18)
11 verbose stack     at Async._drainQueue (/usr/local/lib/nodejs/node-v10.15.1-linux-x64/lib/node_modules/npm/node_modules/bluebird/js/release/async.js:133:
16)
11 verbose stack     at Async._drainQueues (/usr/local/lib/nodejs/node-v10.15.1-linux-x64/lib/node_modules/npm/node_modules/bluebird/js/release/async.js:143
:10)
11 verbose stack     at Immediate.Async.drainQueues [as _onImmediate] (/usr/local/lib/nodejs/node-v10.15.1-linux-x64/lib/node_modules/npm/node_modules/blueb
ird/js/release/async.js:17:14)
11 verbose stack     at runCallback (timers.js:705:18)
11 verbose stack     at tryOnImmediate (timers.js:676:5)
11 verbose stack     at processImmediate (timers.js:658:5)
12 verbose cwd /home/vantage/DAnodeBindings
13 verbose Linux 4.15.0-45-generic
14 verbose argv "/usr/local/lib/nodejs/node-v10.15.1-linux-x64/bin/node" "/usr/local/lib/nodejs/node-v10.15.1-linux-x64/bin/npm" "install" "@da/daml-ledger"
15 verbose node v10.15.1
16 verbose npm  v6.4.1
17 error code E401
18 error 401 Unauthorized: @da/daml-ledger@latest
19 verbose exit [ 1, true ]

我按照第1步和第2步中的说明进行操作。我的.npmrc会以我收到的输入响应进行更新

curl -umehul@digitalassetsdk:<API_KEY> https://api.bintray.com/npm/digitalassetsdk/npm/auth/scope/da

我输入了命令

npm config set @da:registry https://api.bintray.com/npm/digitalassetsdk/npm

是什么原因导致错误?

2 个答案:

答案 0 :(得分:1)

从注释中看来,您错过了设置的步骤,也就是说,按照说明告诉您将curl的响应粘贴到~/.npmrc

  

应将响应粘贴到〜/ .npmrc(在Windows%USERPROFILE%/。npmrc中)文件中。

作为替代方案,在Linux和MacOS上,您可以将curl的输出通过管道传递到~/.npmrc,如下所示:

curl -u<USERNAME>:<API_KEY> https://api.bintray.com/npm/digitalassetsdk/npm/auth/scope/da >> ~/.npmrc

使用>>运算符将保留~/.npmrc的当前内容,并将curl的输出附加到文件中(或在文件不存在的情况下创建)。如果您想覆盖当前的~/.npmrc文件,只需使用>运算符即可。

答案 1 :(得分:0)

Bintary的“设置我的指令”(在https://docs.daml.com/app-dev/bindings-js/getting-started.html的步骤1.3中引用)说要运行curl命令,然后要运行

npm config set @<SCOPE>:registry https://api.bintray.com/npm/digitalassetsdk/npm

当我跳过npm config步骤时,我没有问题。