Is it possible to install Wrangler in a CI/CD environment, spcifically BitBucket Pipelines in our case?
If we do npm i @cloudflare/wrangler -g the installation fails with Error: EACCES: permission denied, mkdir '/root/.wrangler':
npm i @cloudflare/wrangler -g
/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:126
throw err;
^
Error: EACCES: permission denied, mkdir '/root/.wrangler'
at mkdirSync (fs.js:764:3)
at Object.<anonymous> (/usr/local/lib/node_modules/@cloudflare/wrangler/install-wrangler.js:60:3)
at Module._compile (internal/modules/cjs/loader.js:776:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:787:10)
at Module.load (internal/modules/cjs/loader.js:643:32)
at Function.Module._load (internal/modules/cjs/loader.js:556:12)
at Function.Module.runMain (internal/modules/cjs/loader.js:839:10)
at internal/main/run_main_module.js:17:11 {
errno: -13,
syscall: 'mkdir',
code: 'EACCES',
path: '/root/.wrangler'
}
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.
If we do npm i @cloudflare/wrangler it installs (installation logs below) but when you try to then run wrangler publish --release we receive bash: wrangler: command not found:
npm i @cloudflare/wrangler
> [email protected] install /opt/atlassian/pipelines/agent/build/node_modules/sleep
> node-gyp rebuild
make: Entering directory '/opt/atlassian/pipelines/agent/build/node_modules/sleep/build'
CXX(target) Release/obj.target/node_sleep/module_init.o
CXX(target) Release/obj.target/node_sleep/sleep_cpp11.o
CXX(target) Release/obj.target/node_sleep/sleep_posix.o
CXX(target) Release/obj.target/node_sleep/sleep_win.o
SOLINK_MODULE(target) Release/obj.target/node_sleep.node
COPY Release/node_sleep.node
make: Leaving directory '/opt/atlassian/pipelines/agent/build/node_modules/sleep/build'
> [email protected] postinstall /opt/atlassian/pipelines/agent/build/node_modules/protobufjs
> node scripts/postinstall
> @cloudflare/[email protected] postinstall /opt/atlassian/pipelines/agent/build/node_modules/@cloudflare/wrangler
> node install-wrangler.js
Downloading release https://github.com/cloudflare/wrangler/releases/download/v1.2.0/wrangler-v1.2.0-x86_64-unknown-linux-musl.tar.gz
Wrangler has been installed!
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
> @cloudflare/[email protected]
added 624 packages from 465 contributors and audited 875670 packages in 16.926s
found 0 vulnerabilities
The above is using a Node 12.6.0 container image, I've also tried a Node 8-jessie image too and changing the user the container is running as to no avail.
Thanks very much!
Hey @matthew1534 - we recommend installing node/npm with a version manager like nvm. Could you try uninstalling node/npm and reinstalling with nvm and then installing wrangler afterwards? Please update if that works! Thanks for the report
Hey @EverlastingBugstopper - thanks for the above super quick reply. I've now managed to get this working using a debian container image and running the below commands:
apt-get update
apt-get -y install wget
wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.34.0/install.sh | bash
source ~/.bashrc
nvm install 12.6.0
npm config set user 0
npm config set unsafe-perm true
npm i @cloudflare/wrangler -g
export CF_API_KEY=$CF_API_KEY
export CF_EMAIL=$CF_EMAIL
wrangler publish --release
We get a sh: 1: node: Permission denied error unless we run npm config set unsafe-perm true which doesn't seem so great?
Thanks :)
You can likely get around this by not running these commands as root. Hope this helps :)
thanks!
Most helpful comment
thanks!