I wanted to start learning to use libp2p and so started up the tutorial documentation and have hit a problem right away.
The Docs: https://docs.libp2p.io/tutorials/getting-started/javascript/
Following along I got to the "Run Libp2p" header. Running the script I get the error message Error: Cannot find module 'libp2p'
When install the module with sudo npm install libp2p
there was an error reading:
ursaNative bindings compilation fail. This is not an issue. Modules that depend on it will use fallbacks.
fs.js:115
throw err;
^
Error: EACCES: permission denied, open './stdout.log'
at Object.openSync (fs.js:439:3)
at Object.writeFileSync (fs.js:1190:35)
at Object.<anonymous> (/home/foss/hello-libp2p/node_modules/ursa-optional/rebuild.js:13:10)
at Module._compile (internal/modules/cjs/loader.js:689:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
at Module.load (internal/modules/cjs/loader.js:599:32)
at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
at Function.Module._load (internal/modules/cjs/loader.js:530:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:742:12)
at startup (internal/bootstrap/node.js:283:19)
npm WARN [email protected] No description
npm WARN [email protected] No repository field.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] install: `node rebuild.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2020-03-29T11_05_48_715Z-debug.log
`
I'm not really sure why there's a permission denied portion of the error as this was run as sudo.The problem seems to revolve around that ursa script. Although it might be optional I'm not sure. Does anyone who has worked with libp2p seen this before?
I'm using node12.16.1 and npm6.13.4 on ubuntu 19.10
Figured it out. Needed to, instead of running
sudo npm i libp2p
after manually installing the binaries, I had to just skip the sudo and it all works fine. This cause a problem though because I can't install modules globally now because using sudo throws the no npm command found.... I'm not too sure how to add the npm path back into the commands for sudo, or why npm is not present in sudo but is regularly.... This is strange. Will likely be resolved with other distros that natively support node v12 instead of v10. Hopefully 20.04lts will fix this.