annyoung

define npm global path on mac 본문

운영체제

define npm global path on mac

nopsled 2019. 7. 7. 16:04

This post will be handling solve to Command not found npm packages when you installed that.

 

nopsled@playground:~/VisualProjects/react-native-projects (=`ω´=)$ expo
-bash: expo: command not found

I'm tring to use expo-cli on my mac. but it will be occur error when i typing like that. so can't be use this command.

* I was installed that using by global options.

 

nopsled@playground:~/VisualProjects/react-native-projects (=`ω´=)$ npm bin -g
/usr/local/Cellar/node/11.4.0/lib/node_modules/node/bin
(not in PATH env variable)

 

nopsled@playground:~/VisualProjects/react-native-projects (=`ω´=)$ npm config get prefix
/usr/local/Cellar/node/11.4.0/lib/node_modules/node

 

nopsled@playground:~/VisualProjects/react-native-projects (=`ω´=)$ npm bin
/Users/nopsled/VisualProjects/react-native-projects/node_modules/.bin

 

nopsled@playground:~/VisualProjects/react-native-projects (=`ω´=)$ npm bin -g
/usr/local/Cellar/node/11.4.0/lib/node_modules/node/bin
(not in PATH env variable)

Finally, i understood this path configuration fucked.

 

$ npm config set prefix /usr/local/Cellar/node/11.4.0/lib/node_modules/node/bin

You can set npm global path by manually typed:

`npm config set prefix`

 

If you done that command, you shoulde be modify your .bash_profile or /etc/profile.

 

# MacPorts Installer addition on 2015-09-21_at_21:31:26: adding an appropriate PATH variable for use with MacPorts.
#export PATH="/usr/local/bin/:/opt/local/bin:/opt/local/sbin:/usr/local/mysql/bin:/usr/local/mysql/support-files:$PATH"
export PATH="/usr/local/bin/:/opt/local/bin:/opt/local/sbin:$PATH"
#export PATH=$PATH:~/.npm-global/bin
export PATH=/usr/local/Cellar/node/11.4.0/lib/node_modules/node/bin:$PATH
# Finished adapting your PATH environment variable for use with MacPorts.

Add your location which npm global path to your bash_history at last line.

 

and applying your bash_profile using this:

   $ source /etc/profile

   or

   $ source ~/.bash_profile

 

nopsled@playground:~/VisualProjects/react-native-projects (=`ω´=)$ expo init hello
? Choose a template: (Use arrow keys)
  ----- Managed workflow -----
❯ blank               minimal dependencies to run and an empty root component
  blank (TypeScript)  same as blank but with TypeScript configuration
  tabs                several example screens and tabs using react-navigation
  ----- Bare workflow -----
  bare-minimum        minimal setup for using unimodules

Finally, you can use global npm executable binaries.

 

 

삽질 끝.

 

 

 

Comments