'How do you install pub "zsh: command not found: pub" within Flutter application?

I am just starting to learn Flutter. I come from an Angular background and used yarn, npm, which can be installed by brew. I am familiar with these package managers but not pub.

How do you install pub so the command works globally?

Looking for a command line to run.

I am on macOS Catalina

This is what I've tried so far:

I am trying to install the http package with: pub get

however I get this error: zsh: command not found: pub

I then tried to install pub with this line: sudo ln -s /usr/lib/dart/bin/pub /usr/bin/pub

And get this error: ln: /usr/bin/pub: Operation not permitted

I then tried to install sudo by running: /usr/bin/sudo /usr/sbin/diskutil unmountDisk force /dev/disk1

Then I get this error: Forced unmount of disk1 failed: at least one volume could not be unmounted

As I am going down this rabbit hole - I thought I would see if you guys had any suggestions!



Solution 1:[1]

Use flutter pub <command> or dart pub <command> e.g. flutter pub getinstead of trying to usepub` directly.


Flutter maintains its own version of Dart internally and unless you've installed Dart explicitly pub will not be available in your PATH.


Edit

Standalone pub is deprecated and removed.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1