I am trying to install Wrangler CLI for cloudflare into an Ubuntu 19.10 Desktop VM. No matter what I do, I am getting an EACCES error, which is weird, because I opened a root shell using sudo -s before running npm:
npm i -g @cloudflare/wrangler
/usr/local/bin/wrangler -> /usr/local/lib/node_modules/@cloudflare/wrangler/run-wrangler.js
@cloudflare/[email protected] postinstall /usr/local/lib/node_modules/@cloudflare/wrangler
node install-wrangler.js
fs.js:115
throw err;
^
Error: EACCES: permission denied, mkdir ‘/root/.wrangler’
at mkdirSync (fs.js:753:3)
at Object. (/usr/local/lib/node_modules/@cloudflare/wrangler/install-wrangler.js:57:3)
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)
at bootstrapNodeJSCore (internal/bootstrap/node.js:743:3)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @cloudflare/[email protected] postinstall: node install-wrangler.js
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the @cloudflare/[email protected] postinstall 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-01-04T16_04_25_890Z-debug.log
First, I tried using the version of npm and nodejs provided by Ubuntu:
$ sudo apt install npm
Then, when it failed, I tried updating npm:
npm i -g [email protected]
After that updated, I exited my terminal completely, then opened a new term window, sudo -s to become root, and verified that npm was updated by using:
npm --version
6.13.4
Still, the same error.
Then, after reviewing install docs for Wrangler, I saw that they suggested uninstalling the version packaged by the distro, and using a node version manager to install node + npm, then updating npm, then installing.
So, I uninstalled npm and node using apt, then downloaded nvm, ran it to install the latest nodejs + npm, and tried the Wrangler install again, but I keep getting the same EACCES error, even though I’m running as root.
Can anyone help?