Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrangler unable to be installed #3

Closed
ankit8697 opened this issue Apr 15, 2020 · 27 comments
Closed

Wrangler unable to be installed #3

ankit8697 opened this issue Apr 15, 2020 · 27 comments

Comments

@ankit8697
Copy link

I've used NPM to install wrangler but every time I try to use the CLI, I get the following message:

      throw `You have not installed ${this.name ? this.name : "this package"}`;
      ^
You have not installed wrangler

I'm not sure how to fix this. I tried searching for a solution online and in the wrangler docs but couldn't find anything. What should I do?

@BrChung
Copy link

BrChung commented Apr 15, 2020

I would double check your Node/NPM version. There are alternative ways to install Wrangler such as Cargo. See here.

@jialin-wu-02
Copy link

Relevant Issue here: wrangler#240

@ankit8697
Copy link
Author

I've tried using Cargo and I've tried all the recommendations in wrangler#240 but none of them worked for me.

@paridhikhaitan
Copy link

I would try uninstalling and reinstalling npm from your system.

@karakotineeraj
Copy link

I am having trouble installling wrangler on my computer as well.
None of the methods seem to work on my computer.
I am using Ubuntu 18.04 LTS.

@zllovesuki
Copy link

zllovesuki commented Apr 15, 2020

If npm nor cargo works, try doing the manual installation method and put the binary in your PATH (remember to +x).

If you have to, install nvm and use nvm to manage your nodejs installation instead of using nodejs from the OS package manager, then npm -g should work.

@SaipranavK
Copy link

SaipranavK commented Apr 15, 2020

Check if a package.json exists at project root.
If not, then create one with:
npm install -g express
npm init -y

then
npm uninstall -g @cloudflare/wrangler && npm install -g @cloudflare/wrangler

works on Ubuntu 20.04 'Focal Fossa'

@cloudflare-internship-2020
Copy link
Owner

@ankit8697
Copy link
Author

If npm nor cargo works, try doing the manual installation method and put the binary in your PATH (remember to +x).

If you have to, install nvm and use nvm to manage your nodejs installation instead of using nodejs from the OS package manager, then npm -g should work.

So using npm and cargo both put wrangler in my path, but every time I try to use it I get the same error as before which says that you have not installed wrangler. So it's in my path but using it says that I haven't installed it.

Here is the full trace:

internal/modules/cjs/loader.js:955
  throw err;
  ^

Error: Cannot find module '/Users/ankitsanghi/Desktop/Ankit/Projects/cloudflare-webdev-test/wrangler'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:952:15)
    at Function.Module._load (internal/modules/cjs/loader.js:835:27)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
    at internal/main/run_main_module.js:17:47 {
  code: 'MODULE_NOT_FOUND',
  requireStack: []
}
Thrown at:
    at Module._resolveFilename (internal/modules/cjs/loader.js:952:15)
    at Module._load (internal/modules/cjs/loader.js:835:27)
    at executeUserEntryPoint (internal/modules/run_main.js:71:12)
    at internal/main/run_main_module.js:17:47

@zllovesuki
Copy link

Looking at your path structure, I assume you are on macOS. How did you install nodejs? Via brew?

@ankit8697
Copy link
Author

Yeah I used brew. Though after seeing people tell me to use nvm I used nvm to install it.

@zllovesuki
Copy link

Did nvm solve your problem (after uninstalling the brew version)?

@ankit8697
Copy link
Author

No it didn't. I've tried all the suggestions people gave but none of them worked.

@zllovesuki
Copy link

zllovesuki commented Apr 15, 2020

  1. Did you git clone your fork of the project?
  2. How does the folder hierarchy look like for your project? Is there a package.json in your project folder?

EDIT: wait nvm, looks like you try to do the wrangler generate route.

@ankit8697
Copy link
Author

Yeah, but I can try cloning the project and trying to use it that way. Though I doubt that will help in any way.

@zllovesuki
Copy link

Well there’s only one way to find out 😅

@ankit8697
Copy link
Author

Didn't fix it. I think I'll try to uninstall a bunch of things and then reinstall everything again after. See what happens.

@zllovesuki
Copy link

zllovesuki commented Apr 15, 2020

@karakotineeraj @ankit8697
How comfortable are you with remote development? If your local development env is giving you a headache, you can try doing the development on a remote machine. After you are done with the project, then you can try and figure out what went wrong on your local machine, and work with CF to find out what is causing the issue.

You can host an dev instance for free:
https://education.github.com/pack - This also gives your credit to register a domain, easy extra credit ;)
https://azure.microsoft.com/en-us/education/
https://aws.amazon.com/education/awseducate/

It will also be a great opportunity to get familiar with the backend side of things (it's "fullstack" after all).

Confirmed working with DigitalOcean's Ubuntu 18.04.3:

root@cf-summer-2020-remote-dev:~# node --version
v10.20.1
root@cf-summer-2020-remote-dev:~# npm --version
6.14.4
root@cf-summer-2020-remote-dev:~# npm install @cloudflare/wrangler -g --unsafe-perm=true --allow-root
/root/.nvm/versions/node/v10.20.1/bin/wrangler -> /root/.nvm/versions/node/v10.20.1/lib/node_modules/@cloudflare/wrangler/run-wrangler.js

> @cloudflare/wrangler@1.8.4 postinstall /root/.nvm/versions/node/v10.20.1/lib/node_modules/@cloudflare/wrangler
> node ./install-wrangler.js

Downloading release https://workers.cloudflare.com/get-npm-wrangler-binary/1.8.4/x86_64-unknown-linux-musl
wrangler has been installed!
+ @cloudflare/wrangler@1.8.4
updated 1 package in 1.87s
root@cf-summer-2020-remote-dev:~# wrangler generate takehome https://github.com/cloudflare-internship-2020/internship-application-fullstack
⬇️ Installing cargo-generate...
 Creating project called `takehome`...
 Done! New project created /root/takehome
 You will need to update the following fields in the created wrangler.toml file before continuing:
 You can find your account_id and zone_id in the right sidebar of the zone overview tab at https://dash.cloudflare.com
- account_id

Alternatively, if running things as root is not your forte, add a user (as --allow-root is not officially supported by CF):

rachel@cf-summer-2020-remote-dev:~$ nvm install 10.20.1

Downloading and installing node v10.20.1...
Downloading https://nodejs.org/dist/v10.20.1/node-v10.20.1-linux-x64.tar.xz...
######################################################################################################################################################################################################################################################### 100.0%
Computing checksum with sha256sum
Checksums matched!
Now using node v10.20.1 (npm v6.14.4)
Creating default alias: default -> 10.20.1 (-> v10.20.1)
rachel@cf-summer-2020-remote-dev:~$ npm -g install @cloudflare/wrangler
/home/rachel/.nvm/versions/node/v10.20.1/bin/wrangler -> /home/rachel/.nvm/versions/node/v10.20.1/lib/node_modules/@cloudflare/wrangler/run-wrangler.js

> @cloudflare/wrangler@1.8.4 postinstall /home/rachel/.nvm/versions/node/v10.20.1/lib/node_modules/@cloudflare/wrangler
> node ./install-wrangler.js

Downloading release https://workers.cloudflare.com/get-npm-wrangler-binary/1.8.4/x86_64-unknown-linux-musl
wrangler has been installed!
+ @cloudflare/wrangler@1.8.4
added 34 packages from 21 contributors in 2.696s
rachel@cf-summer-2020-remote-dev:~$ wrangler generate takehome https://github.com/cloudflare-internship-2020/internship-application-fullstack
⬇️ Installing cargo-generate...
 Creating project called `takehome`...
 Done! New project created /home/rachel/takehome
 You will need to update the following fields in the created wrangler.toml file before continuing:
 You can find your account_id and zone_id in the right sidebar of the zone overview tab at https://dash.cloudflare.com
- account_id

@ankit8697
Copy link
Author

Sounds good. I'll try these out

@zllovesuki
Copy link

zllovesuki commented Apr 15, 2020

@cloudflare-internship-2020 Relevant issue with binary-install: EverlastingBugstopper/binary-install#3

EDIT: It seems that it is universal with non-nvm installation. CF's official recommendation is to use nvm to manage node installation instead of package manager.

For future reference:
If you are looking at this in future and running into the same problem, try installing nvm, and remember to source your new .bashrc (if using bash). Then do npm -g @cloudflare/wrangler

If that fails, come back later. Meanwhile, try to do your development remotely.

@Swatilekha-Roy
Copy link

Hi, @zllovesuki , I have tried everything that you said here religiously but it still seems to not work. I tried the nvm method too, sourced bash and when I try npm -g @clloudflare/wrangler, this is all I keep seeing.
/usr/local/bin/wrangler -> /usr/local/lib/node_modules/@cloudflare/wrangler/run-wrangler.js

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

The 'Downloading release' does not start. Could you please help me out? Also, which remote development platform do you recommend most? Thanks a lot.

@nataliescottdavidson
Copy link

The issue is tracked here. You should always be able to install and use wrangler locally- this is a problem on our end and we've prioritized getting a fix in.

@Swatilekha-Roy
Copy link

Swatilekha-Roy commented Oct 14, 2020 via email

@nataliescottdavidson
Copy link

@Swatilekha-Roy you don't need a zone id or routes if workers_dev = true in your wrangler.toml. The workers docs live here https://developers.cloudflare.com/workers/.

@Swatilekha-Roy
Copy link

Swatilekha-Roy commented Oct 14, 2020 via email

@srinivaskarri1999
Copy link

I've tried everything and finally, this worked for me.
I'm on Ubuntu 20.04.4

  1. Install wrangler with this command npm install -g @cloudflare/wrangler as suggested in docs
  2. If you see this error You have not installed wrangler then follow steps 3 and 4 else you can skip the below steps
  3. navigate to this location /usr/local/lib/node_modules/@cloudflare/wrangler on terminal with this command cd /usr/local/lib/node_modules/@cloudflare/wrangler
  4. Finally run this command node install-wrangler.js

@simultsop
Copy link

4. wrangler

Actually this fixed my issue on PopOS 🤷

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

No branches or pull requests