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

npm install fails #743

Closed
mxdpeep opened this issue Sep 29, 2019 · 9 comments
Closed

npm install fails #743

mxdpeep opened this issue Sep 29, 2019 · 9 comments

Comments

@mxdpeep
Copy link

mxdpeep commented Sep 29, 2019

🐛 Bug Report

Environment

  • operating system: Ubuntu 18.04 WSL 4.4.0-18985-Microsoft (Windows 10 amd64)
  • output of rustc -V: rustc 1.36.0
  • output of node -v: v11.15.0
  • output of wrangler -V: N/A

npm version: 6.7.0

Steps to reproduce

sudo npm i @cloudflare/wrangler -g

What did you expect to see?

install the wrangler package

What did you see instead?

/usr/bin/wrangler -> /usr/lib/node_modules/@cloudflare/wrangler/run-wrangler.js

@cloudflare/wrangler@1.4.0 postinstall /usr/lib/node_modules/@cloudflare/wrangler
node install-wrangler.js

fs.js:119
throw err;
^

Error: EACCES: permission denied, mkdir '/home/mxdpeep/.wrangler'
at mkdirSync (fs.js:773:3)
at Object. (/usr/lib/node_modules/@cloudflare/wrangler/install-wrangler.js:58:3)
at Module._compile (internal/modules/cjs/loader.js:816:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:827:10)
at Module.load (internal/modules/cjs/loader.js:685:32)
at Function.Module._load (internal/modules/cjs/loader.js:620:12)
at Function.Module.runMain (internal/modules/cjs/loader.js:877:12)
at internal/main/run_main_module.js:21:11
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @cloudflare/wrangler@1.4.0 postinstall: node install-wrangler.js
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the @cloudflare/wrangler@1.4.0 postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

@mxdpeep
Copy link
Author

mxdpeep commented Sep 29, 2019

BTW cargo build works

image

@ashleygwilliams
Copy link
Contributor

hey @mxdpeep ! based on the install command you are running (sudo npm i @cloudflare/wrangler -g) it looks like you do not have node installed with a node version manager like n, nvm, or nodist.

if you've installed node without a tool like this, your npm global cache (which npm i -g uses) is in the root directory of your machine and requires root perms to modify.

we recommend using a node version manager, because these tools will install and keep node and it's global cache in your user directory, which won't require these perms. cargo does this by default (which is why the cargo install works.)

if you'd like to use the npm installer, we recommend you reinstall node using a version manager!

@mxdpeep
Copy link
Author

mxdpeep commented Sep 29, 2019

it is a correct installation of node.js from the official site

@xunxky
Copy link

xunxky commented Sep 30, 2019

@ashleygwilliams
this is the first flipp'n package that seriously required to have node installed in userspace.
it should not require that!

@EverlastingBugstopper
Copy link
Contributor

Hey y'all! Thanks for commenting on this and I'm sorry that this is causing so much trouble!

Unfortunately this is actually a fairly common problem with global installs from npm. So much so that they have their own reference page! https://docs.npmjs.com/resolving-eacces-permissions-errors-when-installing-packages-globally

I'd recommend following along there and hopefully that will help work through some of the pain points here.

@xunxky
Copy link

xunxky commented Oct 1, 2019

yes thanks @EverlastingBugstopper
again it is the FIRST time I have encountered that with any package in serveral years.
It does not raise MY confidence with this tool

@ahmedh01
Copy link

Seems like npm install -g @cloudflare/wrangler doesn't work. Getting the following error:

npm ERR! code 1
npm ERR! path /opt/homebrew/lib/node_modules/@cloudflare/wrangler
npm ERR! command failed
npm ERR! command sh -c node ./install-wrangler.js
npm ERR! Downloading release from https://workers.cloudflare.com/get-npm-wrangler-binary/1.16.0/aarch64-apple-darwin
npm ERR! Error fetching release: Request failed with status code 500

Tried it on Mac OS Big Sur
Node v15.11.0
npm v7.11.0

@xunxky
Copy link

xunxky commented May 25, 2021

working through my very old mails and seeing replies here I have to correct my stance on this issue.
While I still do not think requiring user-space install is good practice user-space node installation should be encouraged. The usual PMs will install it in root space and maybe it shouldn't be that way but it's non of your fault

@EverlastingBugstopper 's comment can't be highlighted enough

Unfortunately this is actually a fairly common problem with global installs from npm. So much so that they have their own reference page! https://docs.npmjs.com/resolving-eacces-permissions-errors-when-installing-packages-globally

I'd recommend following along there and hopefully that will help work through some of the pain points here.

apologies if I offended anybody

@nilslice
Copy link
Contributor

@ahmedh01 - this should be working as expected on your system now. If not please let us know, thanks!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants