简体   繁体   中英

zsh: command not found; express

When I try installing globally express-generator it says it succeeds. I can even see it in my list of global apps however when I try running express I run into the title problem : zsh: command not found: express

I'm actually posting this since I don't know where to post the solution.

I ran into this and it took so long and some grey hairs to finally come to the solution I thought to save some one else the trouble.

I already figured out this was a path problem from reading here on stack overflow however accessing said path was the nightmare and also writing the correct one in the correct way was the challenge

zsh: command not found: express

solution I found was first to locate your .zshrc open it in vim or vscode and then look for the line

export PATH=$HOME/bin:/usr/local/bin:$PATH

at this point you are going to need to do some checking ....open another terminal window and type in

yarn --version

mine gave me 1.17.3 note this version number you will need it go back to your .zshrc and on the next line under the 1st export line add another line ( lots of solutions say add but never explicitly tell you how )

export PATH=$HOME/bin:/usr/local/bin:$PATH
export PATH="$PATH:/opt/yarn-1.17.3/bin"

You are not yet done if you are still want to install packages globally and use them you need to add another path which is where yarn actually stores global packages and commands

export PATH=$HOME/bin:/usr/local/bin:$PATH
export PATH="$PATH:/opt/yarn-1.17.3/bin"
export PATH="$(yarn global bin):$PATH"

Save and exit I also suggest clearing you cache and running

source ~/.profile 

this will ensure that the changes you just made are reflected in the system hope this helps.

.zshrc

export PATH=$HOME/bin:/usr/local/bin:$PATH
export PATH="$PATH:/opt/yarn[your version of yarn]/bin"
export PATH="$(yarn global bin):$PATH"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM