0

I am working through Digital Asset Getting Started with Node.js bindings.

Running

npm install @da/daml-ledger

causes the following error message

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

here are the contents of that log file:

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 ]

I followed the instructions in step 1 and step 2. my .npmrc is updated with the response I received from entering

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

and I entered the command

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

What is causing the error?

stefanobaghino
  • 11,253
  • 4
  • 35
  • 63
Meyer Auslander
  • 349
  • 1
  • 10
  • 1
    Hi Meyer. Unfortunately Bintray seem to have had a few issues lately, would you mind just trying again a few times to see if it succeeds? – stefanobaghino Feb 24 '19 at 06:27
  • Tried again and still it having the same problem. – Meyer Auslander Feb 25 '19 at 16:18
  • Are there any requirements for what needs to be input when I run 'npm init'? – Meyer Auslander Feb 25 '19 at 16:20
  • When I went to update my .npmrc I noticed it did not exist. So I created it myself. Maybe this gives a clue as to what is the problem?? – Meyer Auslander Feb 25 '19 at 17:01
  • @MeyerAuslander does it work for you now after creating and updating the `.npmrc`? Here are my `.npmrc` which works on the ping pong example. ``` @da:registry=https://api.bintray.com/npm/digitalassetsdk/npm/ //api.bintray.com/npm/digitalassetsdk/npm/:_authToken=[INSERT_YOUR_TOKEN_HERE] //api.bintray.com/npm/digitalassetsdk/npm/:username=daniel.sun@digitalassetsdk //api.bintray.com/npm/digitalassetsdk/npm/:email=null //api.bintray.com/npm/digitalassetsdk/npm/:always-auth=true ``` – dsun Feb 26 '19 at 01:51
  • Yes, the missing `~/.npmrc` is definitely the problem; as the instructions say, the output of `curl` as to be pasted (or piped) there. – stefanobaghino Feb 26 '19 at 06:11
  • Today `npm install @da/daml-ledger` works fine. Before it wasn't working even though I had created the ~/.npmrc. I guess the problem with Bintary was fixed. – Meyer Auslander Feb 26 '19 at 17:06
  • But this time I did not run the `npm config` command. It seems `npm config` was causing the problem--because now if I run it and then retry running `npm install @da/daml-ledger`, I get the same authorization error I had yesterday... – Meyer Auslander Feb 26 '19 at 17:12
  • Also I am now stuck on the step that says to run `npm install` inside the 'ping-pong' directory. I get the same authorization error. – Meyer Auslander Feb 26 '19 at 17:29

2 Answers2

1

From the comments it appears you missed a step of the setup, namely as the instructions tell you to paste the response of curl to ~/.npmrc.

The response should be pasted in the ~/.npmrc (in Windows %USERPROFILE%/.npmrc) file.

As an alternative, on Linux and MacOS you can just pipe the output of curl to ~/.npmrc as follows:

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

Using the >> operator will preserve the current content of ~/.npmrc and append the output of curl to the file (or create it if it's not there yet). If you want to overwrite the current ~/.npmrc file, just use the > operator instead.

stefanobaghino
  • 11,253
  • 4
  • 35
  • 63
0

The Bintary 'Set Me Up' Instructions (referenced in step 1.3 of https://docs.daml.com/app-dev/bindings-js/getting-started.html) say to run a curl command and the to run

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

When I skip the npm config step I have no problems.

stefanobaghino
  • 11,253
  • 4
  • 35
  • 63
Meyer Auslander
  • 349
  • 1
  • 10
  • But now I have a problem when Retrieving the package identifiers (https://docs.daml.com/packages/bindings-js-docs/tutorial.html#retrieve-the-package-identifiers). Maybe because I skiped the `config` command? My template-ids.json looks wrong. Here are the contents: {"Car.Car":{"packageId":"9158c3e66ac2a78e427307b098f7a45e86ddcb40a9be6a26eea0d363e7b48a10","name":"Car.Car"}} It should have an entry for 'Ping' and 'Pong', not 'Car' – Meyer Auslander Feb 26 '19 at 18:24