'Protractor Mac installation Issue - protractor --version zsh: command not found: protractor

I'm interested in using Protractor for e2e testing. But running into some possible installation issues on a Mac(macOS Catalina). The main problem I'm having is when trying to verify Protractor's version from the command line. I get the following message when entering protractor --version, zsh: command not found: protractor.

Installation steps:

Step 1 : Download and install node.js https://nodejs.org/en/download/ verified node -v v14.17.0 verified npm -v. 6.14.13

Step 2 : Install Protractor

-verify npm install -g protractor

-Cannot verify protractor --version. I get this message: zsh: command not found: protractor.

I know how to solve this issue on a windows laptop. But have no idea how to on a mac. Thanks for any help. image



Solution 1:[1]

The option -g in npm install -g protractor results the protractor is installed to npm global package location, so you need to append the location into PATH environment, otherwise OS can't find it.

You can get that location from prefix of cmd npm config list output.

Or you config global package location to you desired folder by npm config prefix <a absolute folder path>, then append the folder path into PATH environment, run npm install -g protractor

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 yong