Alex Fallenstedt
Alex Fallenstedt

Reputation: 2093

cannot run any npm global command

I cannot run any of my npm global commands.

The root of my global files are at /Users/Alex/.npm-packages/lib/node_modules. I obtained this from running npm -g root

I am trying to run create-react-app <filename>. Create React App is located at /Users/Alex/.npm-packages/lib/node_modules/create-react-app. I can run node createReactApp.js from this directory and spawn a project, however this is very inconvenient.

When I run create-react-app in shell I get zsh: command not found: create-react-app. So I decided to modify my .bash_profile. Currently it looks like this:

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

# NPM
export PATH="$HOME/.npm-packages/bin/:$PATH"
export PATH="$HOME/.npm-packages/lib/node_modules:$PATH"

#Create Reac App
export PATH="$HOME/.npm-packages/lib/node_modules/create-react-app:$PATH"

and I still cannot run any of my npm global commands.

How can I run my npm global commands like create-react-app <filename>? I've been scratching my head for about 40 minutes trying different things, reading various blogs, and numerous github tickets, various stack overflow questions and I still cannot solve this npm problem.

UPDATE

I've included the following to my .bash_profile and then ran source .bash_profile to update my $PATH

PATH=/usr/bin:/bin:/usr/sbin:/sbin
export PATH
PATH=/usr/local/bin:/usr/local/sbin:"$PATH"
PATH=/opt/local/bin:/opt/local/sbin:"$PATH"
...

Now my global commands work.

Upvotes: 0

Views: 1486

Answers (1)

Andy Aldo
Andy Aldo

Reputation: 890

Have you looked into the folder and see if the global npm commands are there? If it does, you can just include /Users/Alex/.npm-packages/bin to your $PATH and it should solve the problem. Otherwise, there is a possibility that you have installed the global packages incorrectly. Hope it helps!

Upvotes: 2

Related Questions