web3 npm install fails - node.js

I seem to be struggling with getting npm to install web3
Command used:
npm install web3
Error:
npm ERR! Path must be a string. Received undefined
Logs:
info it worked if it ends with ok
1 verbose cli [ '/usr/bin/node', '/usr/bin/npm', 'install', 'web3' ]
2 info using npm#5.0.4
3 info using node#v8.1.3
4 verbose npm-session 02c74f27df35fda1
5 silly install loadCurrentTree
6 silly install readLocalPackageData
7 http fetch GET 304 https://registry.npmjs.org/web3 236ms (from cache)
8 silly pacote tag manifest for web3#latest fetched in 269ms
9 verbose stack TypeError: Path must be a string. Received undefined
9 verbose stack at assertPath (path.js:28:11)
9 verbose stack at Object.relative (path.js:1248:5)
9 verbose stack at computeVersionSpec (/usr/lib/node_modules/npm/lib/install/deps.js:282:27)
9 verbose stack at Installer.normalizeCurrentTree (/usr/lib/node_modules/npm/lib/install.js:370:69)
9 verbose stack at Array.<anonymous> (/usr/lib/node_modules/npm/node_modules/slide/lib/bind-actor.js:15:8)
9 verbose stack at LOOP (/usr/lib/node_modules/npm/node_modules/slide/lib/chain.js:15:14)
9 verbose stack at /usr/lib/node_modules/npm/node_modules/slide/lib/chain.js:18:7
9 verbose stack at iferr (/usr/lib/node_modules/npm/lib/install.js:328:5)
9 verbose stack at /usr/lib/node_modules/npm/node_modules/iferr/index.js:13:50
9 verbose stack at cb (/usr/lib/node_modules/npm/node_modules/slide/lib/async-map.js:47:24)
9 verbose stack at /usr/lib/node_modules/npm/node_modules/call-limit/call-limit.js:22:12
9 verbose stack at _combinedTickCallback (internal/process/next_tick.js:95:7)
9 verbose stack at process._tickCallback (internal/process/next_tick.js:161:9)
10 verbose cwd /home/username
11 verbose Linux 4.11.7-1-ARCH
12 verbose argv "/usr/bin/node" "/usr/bin/npm" "install" "web3"
13 verbose node v8.1.3
14 verbose npm v5.0.4
15 error Path must be a string. Received undefined
16 verbose exit [ 1, true ]
I've tried running them with root user as well.

The problem might come from using a beta version of web3 it's not stable at the moment and currently is under heavy development you have one of two options,
either use a stable version 0.19 I think or something like that.
Another thing I would suggest trying is npm --save in order to save the package locally in the project

Related

Failed in adding bootstrap in package.json using npm

I am currently trying to learn react and I cannot add bootstrap as a dependency in my package.json using npm. I am trying the command npm install bootstrap in my terminal and I am in my current project directory. Here is the error:
0 info it worked if it ends with ok
1 verbose cli [
1 verbose cli '/home/lan/.nvm/versions/node/v14.17.0/bin/node',
1 verbose cli '/home/lan/.nvm/versions/node/v14.17.0/bin/npm',
1 verbose cli 'install',
1 verbose cli 'bootstrap',
1 verbose cli '--save'
1 verbose cli ]
2 info using npm#6.14.13
3 info using node#v14.17.0
4 verbose npm-session 2a73fc2953f50908
5 silly install loadCurrentTree
6 silly install readLocalPackageData
7 http fetch GET 304 https://registry.npmjs.org/bootstrap 470ms (from cache)
8 silly fetchPackageMetaData error for bootstrap#^5.0.1 Unexpected end of JSON input while parsing near '..."shx":"^0.1.2","time-'
9 timing stage:rollbackFailedOptional Completed in 2ms
10 timing stage:runTopLevelLifecycles Completed in 596ms
11 verbose stack SyntaxError: Unexpected end of JSON input while parsing near '..."shx":"^0.1.2","time-'
11 verbose stack at JSON.parse (<anonymous>)
11 verbose stack at parseJson (/home/lan/.nvm/versions/node/v14.17.0/lib/node_modules/npm/node_modules/json-parse-better-errors/index.js:7:17)
11 verbose stack at /home/lan/.nvm/versions/node/v14.17.0/lib/node_modules/npm/node_modules/node-fetch-npm/src/body.js:96:50
11 verbose stack at processTicksAndRejections (internal/process/task_queues.js:95:5)
12 verbose cwd /media/lan/3561-3761/WebProjects/LearnReact
13 verbose Linux 5.8.0-53-generic
14 verbose argv "/home/lan/.nvm/versions/node/v14.17.0/bin/node" "/home/lan/.nvm/versions/node/v14.17.0/bin/npm" "install" "bootstrap" "--save"
15 verbose node v14.17.0
16 verbose npm v6.14.13
17 error Unexpected end of JSON input while parsing near '..."shx":"^0.1.2","time-'
18 verbose exit [ 1, true ]
I am currently in a Ubuntu 20.04.2 LTS OS.

NPM Error The value "4294967295" is invalid for option "family"

Problem
I can't seem to install and packages using npm. It seems to be a DNS query issue. Has anyone found a way to fix this?
Software
node --version v10.18.1
npm --version 6.13.4
OS
Virtualization: qemu
Operating System: Ubuntu 18.04.3 LTS
Kernel: Linux 4.15.0-55-generic
Architecture: x86-64
Logs
1 verbose cli [ '/usr/bin/node', '/usr/bin/npm', 'install', 'webpack' ]
2 info using npm#6.13.4
3 info using node#v10.18.1
4 verbose npm-session 854255086166d555
5 silly install loadCurrentTree
6 silly install readLocalPackageData
7 silly fetchPackageMetaData error for webpack#^4.17.0 The value "4294967295" is invalid for option "family"
8 timing stage:rollbackFailedOptional Completed in 49ms
9 timing stage:runTopLevelLifecycles Completed in 3593ms
10 verbose stack TypeError [ERR_INVALID_OPT_VALUE]: The value "4294967295" is invalid for option "family"
10 verbose stack at lookup (dns.js:112:11)
10 verbose stack at net.js:1004:5
10 verbose stack at defaultTriggerAsyncIdScope (internal/async_hooks.js:294:19)
10 verbose stack at lookupAndConnect (net.js:1003:3)
10 verbose stack at TLSSocket.Socket.connect (net.js:938:5)
10 verbose stack at Object.connect (_tls_wrap.js:1165:13)
10 verbose stack at HttpsAgent.createConnection (https.js:120:22)
10 verbose stack at HttpsAgent.createSocket (/usr/lib/node_modules/npm/node_modules/agentkeepalive/lib/_http_agent.js:265:26)
10 verbose stack at HttpsAgent.createSocket (/usr/lib/node_modules/npm/node_modules/agentkeepalive/lib/agent.js:77:11)
10 verbose stack at HttpsAgent.addRequest (/usr/lib/node_modules/npm/node_modules/agentkeepalive/lib/_http_agent.js:239:10)
10 verbose stack at new ClientRequest (_http_client.js:249:16)
10 verbose stack at request (https.js:289:10)
10 verbose stack at fetch.Promise (/usr/lib/node_modules/npm/node_modules/node-fetch-npm/src/index.js:54:17)
10 verbose stack at new Promise (<anonymous>)
10 verbose stack at fetch (/usr/lib/node_modules/npm/node_modules/node-fetch-npm/src/index.js:41:10)
10 verbose stack at retry (/usr/lib/node_modules/npm/node_modules/make-fetch-happen/index.js:332:14)
11 verbose cwd /var/www/magellan/app
12 verbose Linux 4.15.0-55-generic
13 verbose argv "/usr/bin/node" "/usr/bin/npm" "install" "webpack"
14 verbose node v10.18.1
15 verbose npm v6.13.4
16 error code ERR_INVALID_OPT_VALUE
17 error The value "4294967295" is invalid for option "family"
18 verbose exit [ 1, true ]
Maybe this is somehow related to this issue described in the balena forum:
the mentioned exception comes probably from the dns.js in node and may be a result from a "mysterious" variable intialization:
family = options.family >>> 0;
It looks like that an undefined value for family gets evaluated to "4294967295" instead of "0" while using QEMU.
If you have access to the code for the underlying call (at net.js:1004:5), maybe you can do a similiar workaround and add a fixed value for this family-parameter to the "lookup" function call.

Node.js bindings for a Digital Asset Ledger Project

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?
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.
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.

Error installing Typescript using npm

When I try installing Typescript with npm, I get an error:
npm ERR! Unexpected end of JSON input while parsing near '...latest","mocha":"late'
This is the content of the log file:
0 info it worked if it ends with ok
1 verbose cli [ '/usr/local/bin/node',
1 verbose cli '/usr/local/bin/npm',
1 verbose cli 'i',
1 verbose cli 'typescript',
1 verbose cli '--save-dev' ]
2 info using npm#6.0.1
3 info using node#v10.0.0
4 verbose npm-session d4b7b23a6f27323f
5 silly install loadCurrentTree
6 silly install readLocalPackageData
7 http fetch GET 200 https://registry.npmjs.org/typescript 28ms (from cache)
8 silly fetchPackageMetaData error for typescript#latest Unexpected end of JSON input while parsing near '...latest","mocha":"late'
9 verbose stack SyntaxError: Unexpected end of JSON input while parsing near '...latest","mocha":"late'
9 verbose stack at JSON.parse (<anonymous>)
9 verbose stack at parseJson (/usr/local/lib/node_modules/npm/node_modules/pacote/node_modules/make-fetch-happen/node_modules/node-fetch-npm/node_modules/json-parse-better-errors/index.js:7:17)
9 verbose stack at consumeBody.call.then.buffer (/usr/local/lib/node_modules/npm/node_modules/pacote/node_modules/make-fetch-happen/node_modules/node-fetch-npm/src/body.js:96:50)
9 verbose stack at process._tickCallback (internal/process/next_tick.js:178:7)
10 verbose cwd /Users/Bayo/Documents/Personal/Learning/tstest
11 verbose Darwin 16.7.0
12 verbose argv "/usr/local/bin/node" "/usr/local/bin/npm" "i" "typescript" "--save-dev"
13 verbose node v10.0.0
14 verbose npm v6.0.1
15 error Unexpected end of JSON input while parsing near '...latest","mocha":"late'
16 verbose exit [ 1, true ]
My current npm version is 6.0.1
My current node version is 10.0.0

E404 when trying to link local npm module

I am getting a 404 error when trying to link a local module with npm following the docs
Inside the local module directory seems like it creates a global link correctly:
$ npm link
/usr/local/lib/node_modules/my-module-name -> /Users/XXX/my-module-directory/my-module-name
But when just after that I try to link this from other project directory i get an 404 error:
$ npm link my-module-name
npm ERR! code E404
npm ERR! 404 Not Found: my-module-name#latest
I've tried to unlink the module and link again or change versions but it doesn't work.
Here is full log:
0 info it worked if it ends with ok
1 verbose cli [ '/Users/XXX/.nvm/versions/node/v8.2.1/bin/node',
1 verbose cli '/Users/XXX/.nvm/versions/node/v8.2.1/bin/npm',
1 verbose cli 'link',
1 verbose cli 'my-module-name' ]
2 info using npm#5.3.0
3 info using node#v8.2.1
4 verbose npm-session 7d82e8d8dc1bdc83
5 silly install loadCurrentTree
6 silly install readGlobalPackageData
7 http fetch GET 404 https://registry.npmjs.org/my-module-name 2304ms
8 silly fetchPackageMetaData error for my-module-name#latest 404 Not Found: my-module-name#latest
9 verbose stack Error: 404 Not Found: my-module-name#latest
9 verbose stack at fetch.then.res (/Users/XXX/.nvm/versions/node/v8.2.1/lib/node_modules/npm/node_modules/pacote/lib/fetchers/registry/fetch.js:41:19)
9 verbose stack at tryCatcher (/Users/XXX/.nvm/versions/node/v8.2.1/lib/node_modules/npm/node_modules/bluebird/js/release/util.js:16:23)
9 verbose stack at Promise._settlePromiseFromHandler (/Users/XXX/.nvm/versions/node/v8.2.1/lib/node_modules/npm/node_modules/bluebird/js/release/promise.js:512:31)
9 verbose stack at Promise._settlePromise (/Users/XXX/.nvm/versions/node/v8.2.1/lib/node_modules/npm/node_modules/bluebird/js/release/promise.js:569:18)
9 verbose stack at Promise._settlePromise0 (/Users/XXX/.nvm/versions/node/v8.2.1/lib/node_modules/npm/node_modules/bluebird/js/release/promise.js:614:10)
9 verbose stack at Promise._settlePromises (/Users/XXX/.nvm/versions/node/v8.2.1/lib/node_modules/npm/node_modules/bluebird/js/release/promise.js:693:18)
9 verbose stack at Async._drainQueue (/Users/XXX/.nvm/versions/node/v8.2.1/lib/node_modules/npm/node_modules/bluebird/js/release/async.js:133:16)
9 verbose stack at Async._drainQueues (/Users/XXX/.nvm/versions/node/v8.2.1/lib/node_modules/npm/node_modules/bluebird/js/release/async.js:143:10)
9 verbose stack at Immediate.Async.drainQueues (/Users/XXX/.nvm/versions/node/v8.2.1/lib/node_modules/npm/node_modules/bluebird/js/release/async.js:17:14)
9 verbose stack at runCallback (timers.js:781:20)
9 verbose stack at tryOnImmediate (timers.js:743:5)
9 verbose stack at processImmediate [as _immediateCallback] (timers.js:714:5)
10 verbose cwd /Users/XXX/my-project-directory
11 verbose Darwin 16.6.0
12 verbose argv "/Users/XXX/.nvm/versions/node/v8.2.1/bin/node" "/Users/XXX/.nvm/versions/node/v8.2.1/bin/npm" "link" "my-module-name"
13 verbose node v8.2.1
14 verbose npm v5.3.0
15 error code E404
16 error 404 Not Found: my-module-name#latest
17 verbose exit [ 1, true ]
You're using an NVM-installed version of Node.js to run npm link my-module-name, but you didn't run npm link (in your module's directory) using that same version.
The initial link is created in /usr/local/lib/node_modules, but when you use NVM, each Node.js version gets their own "lib" directory, in your example /Users/XXX/.nvm/versions/node/v8.2.1/lib/node_modules, which is a different directory.

Resources