Skip to content
This repository has been archived by the owner on Aug 3, 2023. It is now read-only.

npm install -g @cloudflare/wrangler Error: EACCES: permission denied, mkdir #1517

Closed
JasonCoombs opened this issue Aug 22, 2020 · 6 comments
Closed
Labels
bug Something isn't working onboarding Issues with installation or login

Comments

@JasonCoombs
Copy link
Contributor

🐛 Bug Report

NOTE:
Please fill out each section below before submitting your 🐛 bug report.

Before opening a new issue, please:

BUG REPORT TEMPLATE PROBLEM:

404 NOT FOUND on https://workers.cloudflare.com/docs/quickstart/updating-the-cli/

Environment

  • operating system: macOS 10.15.5 (output of sw_vers -productVersion)
  • output of rustc -V: rustc 1.45.2
  • output of node -v: v14.8.0
  • output of wrangler -V: 👷 ✨ wrangler 1.11.0 (after successful installation)
  • contents of wrangler.toml

Steps to reproduce

  1. install nodejs using binary package installer, e.g. https://nodejs.org/en/download/
  2. $ sudo npm install -g @cloudflare/wrangler
  3. fake success message:
Downloading release https://workers.cloudflare.com/get-npm-wrangler-binary/1.11.0/x86_64-apple-darwin
wrangler has been installed!
+ @cloudflare/wrangler@1.11.0
updated 1 package in 5.075s
  1. attempt to verify successful installation: $ wrangler -V
Error: spawnSync /Users/jasoncoombs/.wrangler/bin/wrangler ENOENT
    at Object.spawnSync (internal/child_process.js:1070:20)
    at spawnSync (child_process.js:602:24)
    at Binary.run (/usr/local/lib/node_modules/@cloudflare/wrangler/node_modules/binary-install/src/binary.js:131:20)
    at run (/usr/local/lib/node_modules/@cloudflare/wrangler/binary.js:39:10)
    at Object.<anonymous> (/usr/local/lib/node_modules/@cloudflare/wrangler/run-wrangler.js:4:1)
    at Module._compile (internal/modules/cjs/loader.js:1251:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1272:10)
    at Module.load (internal/modules/cjs/loader.js:1100:32)
    at Function.Module._load (internal/modules/cjs/loader.js:962:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12) {
  errno: -2,
  code: 'ENOENT',
  syscall: 'spawnSync /Users/jasoncoombs/.wrangler/bin/wrangler',
  path: '/Users/jasoncoombs/.wrangler/bin/wrangler',
  spawnargs: [ '-V' ]
}
  1. google "Error: spawnSync wrangler"
  2. read Unable to install wrangler globally inside a Docker container when I have root access. #803
  3. down the rabbit hole to Unable to install wrangler globally inside a Docker container when I have root access. #803

#803 (comment)

  1. install nvm

$ nvm ls
-> v14.8.0
system
default -> node (-> v14.8.0)
node -> stable (-> v14.8.0) (default)
stable -> 14.8 (-> v14.8.0) (default)


10. `$ nvm install node`

Downloading and installing node v14.8.0...
Downloading https://nodejs.org/dist/v14.8.0/node-v14.8.0-darwin-x64.tar.xz...
############################################################################################################### 100.0%
Computing checksum with shasum -a 256
Checksums matched!
Now using node v14.8.0 (npm v6.14.7)
Creating default alias: default -> node (-> v14.8.0)


11. verify nvm version of npm instead of system-install:

$ which npm
/Users/jasoncoombs/.nvm/versions/node/v14.8.0/bin/npm


12. try again to npm install -g (note: no longer requires sudo but [probably?] nvm doesn't truly install wrangler globally):

$ npm install -g @cloudflare/wrangler
/Users/jasoncoombs/.nvm/versions/node/v14.8.0/bin/wrangler -> /Users/jasoncoombs/.nvm/versions/node/v14.8.0/lib/node_modules/@cloudflare/wrangler/run-wrangler.js

@cloudflare/wrangler@1.11.0 postinstall /Users/jasoncoombs/.nvm/versions/node/v14.8.0/lib/node_modules/@cloudflare/wrangler
node ./install-wrangler.js

Downloading release https://workers.cloudflare.com/get-npm-wrangler-binary/1.11.0/x86_64-apple-darwin
wrangler has been installed!

  • @cloudflare/wrangler@1.11.0
    added 34 packages from 21 contributors in 3.732s
    $ wrangler -V
    👷 ✨ wrangler 1.11.0

13. SUCCESS

#### What did you expect to see?

wrangler global installation successful using system nodejs installation from global binary package installer

#### What did you see instead?

wrangler installation failed with `npm ERR! code ELIFECYCLE`

mandatory requirement for nvm (not explained in the documentation, not found in searching known Issues)
@JasonCoombs
Copy link
Contributor Author

This closed issue is related #240 and it also suggested modifying the documentation to indicate nvm is a requirement.

Installation instructions still lacking nvm here: https://github.com/cloudflare/wrangler

Installation instructions still lacking nvm here: https://developers.cloudflare.com/workers/

Installation instructions include the following incorrect step:

"Ensure you have npm installed"

https://www.npmjs.com/get-npm

Installation instructions need to include the following detail instead of leading user to believe it will work to install npm using a binary global package:

"NOTE: MUST USE a Node.js version manager or configure root or default system account permissions manually (possible but complicated, not recommended)."

@JasonCoombs
Copy link
Contributor Author

Created PR cloudflare/cloudflare-docs-engine#191

@JasonCoombs
Copy link
Contributor Author

Created PR #1518

@ScottSmith95
Copy link

As a new user to Cloudflare Workers, this really threw me for a loop. It's only in this thread that I've found nvm is a requirement. I use n to manage node versions so it's a bit of a pain too.

@iandelahorne
Copy link

This bit us really hard for our CI containers, which just install nodejs and don't use nvm. We had to resort to installing wrangler via cargo which was a bit of a pain.

@Electroid Electroid added bug Something isn't working onboarding Issues with installation or login and removed user report labels Feb 22, 2021
@xortive
Copy link
Contributor

xortive commented Feb 25, 2021

closing since it looks like the docs PR has been merged to recommend nvm as part of onboarding on the docs site.

@iandelahorne I think #1780 may be of interest to you, which allows you to configure exactly where you want to install wrangler which should be useful for CI.

@xortive xortive closed this as completed Feb 25, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working onboarding Issues with installation or login
Projects
None yet
Development

No branches or pull requests

5 participants