npm 전역 경로 접두사
나는 npm과거 의 행동으로 혼란스러워서 평소보다 더 조심 스럽습니다 .
나는 Mac에 있고를 통해 node.js를 설치했습니다 brew install node.
이제 jslint.js명령으로 명령 행 에서 실행하고 싶습니다. jslint이 작업을 수행하는 정식 방법은 sudo npm install -g jslint이 출력에서 성공적으로 실행 된 것입니다.
$ sudo npm install -g jslint
npm http GET https://registry.npmjs.org/jslint
npm http 200 https://registry.npmjs.org/jslint
npm http GET https://registry.npmjs.org/jslint/-/jslint-0.1.9.tgz
npm http 200 https://registry.npmjs.org/jslint/-/jslint-0.1.9.tgz
npm http GET https://registry.npmjs.org/nopt
npm http 200 https://registry.npmjs.org/nopt
npm http GET https://registry.npmjs.org/nopt/-/nopt-1.0.10.tgz
npm http 200 https://registry.npmjs.org/nopt/-/nopt-1.0.10.tgz
npm http GET https://registry.npmjs.org/abbrev
npm http 200 https://registry.npmjs.org/abbrev
npm http GET https://registry.npmjs.org/abbrev/-/abbrev-l.0.4.tgz
npm http 200 https://registry.npmjs.org/abbrev/-/abbrev-1.0.4.tgz
/usr/local/share/npm/bin/jslint -> /usr/local/share/npm/lib/node_modules/jslint/
bin/jslint.js
jslint@0.1.9 /usr/local/share/npm/lib/node_modules/jslint
└── nopt@1.0.10 (abbrev@1.0.4)
그후
$ jslint ply.js
zsh: command not found: jslint
때문에이하는 /usr/local/share/npm/bin내에있는 없습니다 $PATH.
1) brew전역 npm bin경로를 설치 하지 않은 이유는 무엇 입니까? 어쩌면 그럴 수도 있지만 무언가 zsh가 엉망입니다. 어디서 찾을 수 있을까요?
2) 내가해야합니까? ( 내 바닥에 내 :/usr/local/share/npm/bin보낸 부분 $PATH에 추가 ~/.zshrc)
나중에 다른 것을 설치하면 (Homebrew 또는 다른 것을 사용하여) 경로를 설정하기 위해 zsh 시작 스크립트에 추가해야하기 때문에 이것이 올바른 방법이 아닌 것 같습니다. 이 특별한 경우에는 npm install -g"적절한"위치에서 올바른 심볼릭 링크를 만들지 않는 것이 문제 일 /usr/local/bin것입니다.
내가 할 일은 /usr/local/bin문제가있는 프로그램을 위해 내부 에 심볼릭 링크를 수동으로 작성하는 것이며 내 목적에 충분해야한다고 생각합니다.
편집 : 나는이 오래된 질문이 대중적이지만 지금은 내 개인 워크 플로우와 노드 설치 및 다양한 종속성 관리에 대한 최선의 방법 측면에서 구식이기 때문에 2019 년에 이것을 업데이트하고 있습니다.
개인 워크 플로는 이제 nodejs.org에서 얻은 설치 프로그램을 사용하여 시스템에 노드를 설치합니다. 필자는 실제로 파일을 관리하는 가장 좋은 방법을 알고 있기 때문에 homebrew 패키지 자체보다 이것을 신뢰합니다. Mac 또는 Windows에서 시스템 노드를 8.10에서 10.15로 변경하려면 OS 용 10.15의 nodejs.org에서 설치 프로그램을 다운로드하십시오. homebrew를 통해 설치된 노드를 업그레이드하려고 시도하는 것은 항상 내 경험상 더 어려운 접근법으로 입증되었습니다.
또한, 가장 큰 지적은 위의 jslint 예제의 npm 설치에 표시된 것처럼 sudo를 사용하지 않는 것이 좋습니다. 나는 수퍼 유저를 사용하여 어떤 방식 으로든자가 양조 패키지를 설치하거나 상호 작용해서는 안된다는 것을 확신합니다. 필요하지 않아야하며 파일 권한 두통으로 이어질 것입니다!
또한 jslint보다 ESLint를 권장하며 수년 동안 jslint를 사용하지 않았습니다.
당신의 확장 PATH:
export PATH=/usr/local/share/npm/bin:$PATH
끔찍한 생각이 아닙니다. 그렇게 말한 후에는 할 필요가 없습니다.
이것을 실행하십시오 :
npm config get prefix
OS X의 기본값은 /usr/local입니다. 즉, npm은 바이너리를로 연결합니다 /usr/local/bin.이 바이너리 는 이미 PATH(특히 Homebrew를 사용하는 경우) 에 있어야합니다 .
그래서:
npm config set prefix /usr/local다른 것이면sudonpm과 함께 사용하지 마십시오 ! jslint docs 에 따르면 , 당신은 그것을 할 수 있어야npm install합니다.
npm을 sudo ( sudo brew install)로 설치 한 경우 일반 ol '로 다시 설치하십시오 brew install. Homebrew는 당신을 sudo자유롭게 해줄 것 입니다.
이 문제에 시간을 보냈는데 PATH 스위치가 도움이되지 않았습니다. 내 문제는 브루 / 노드 / 고궁 박물원 버그가 여기 있었다 - https://github.com/npm/npm/issues/3794
Homebrew를 사용하여 이미 노드를 설치 한 경우 **** 안전하지 않을 수도 있다는 설명에 따라 참고하십시오. 그것은 나를 위해 일했지만 의도하지 않은 결과를 초래할 수 있습니다. 또한 최신 버전의 Homebrew가 npm을 올바르게 설치하는 것으로 보입니다. 그래서 아마 내가 시도 할 것이다 brew update, brew doctor, brew upgrade node**** 시도하기 전에 등 :
npm update -gf
또는 Homebrew로 노드를 설치하고 npm이 작동하려면 다음을 사용하십시오.
brew install node --without-npm
curl -L https://npmjs.org/install.sh | sh
brew를 사용하고 접두사가 이미 다음과 같이 설정되었습니다.
$ npm config get prefix
/Users/[user]/.node
bin과 lib 폴더가 root에 의해 소유되어 일반적인 sudo 설치를 막았으므로 사용자에게 다시 소유했습니다.
$ cd /Users/[user]/.node
$ chown -R [user]:[group] lib
$ chown -R [user]:[group] bin
그런 다음 / Users / [user]에있는 .bash_profile에 경로를 추가했습니다.
PATH=$PATH:~/.node/bin
brew should not require you to use sudo even when running npm with -g. This might actually create more problems down the road.
Typically, brew or port let you update you path so it doesn't risk messing up your .zshrc, .bashrc, .cshrc, or whatever flavor of shell you use.
Any one got the same issue it's related to a conflict between brew and npm Please check this solution https://gist.github.com/DanHerbert/9520689
I managed to fix Vue Cli no command error by doing the following:
- In terminal
sudo nano ~/.bash_profileto edit your bash profile. - Add
export PATH=$PATH:/Users/[your username]/.npm-packages/bin - Save file and restart terminal
- Now you should be able to use
vue create my-projectandvue --versionetc.
I did this after I installed the latest Vue Cli from https://cli.vuejs.org/
I generally use yarn, but I installed this globally with npm npm install -g @vue/cli. You can use yarn too if you'd like yarn global add @vue/cli
Note: you may have to uninstall it first globally if you already have it installed: npm uninstall -g vue-cli
Hope this helps!
Simple solution is ...
Just put below command :
sudo npm config get prefixif it's not something like these
/usr/local, than you need to fix it using below command.sudo npm config set prefix /usr/local...
Now it's 100% working fine
Try running:
PATH=$PATH:~/npm/bin
and then do a test by running express in the command line. This worked for me.
If you have linked the node packages using sudo command
Then go to the folder where node_modules are installed globally.
On Unix systems they are normally placed in /usr/local/lib/node or /usr/local/lib/node_modules when installed globally. If you set the NODE_PATH environment variable to this path, the modules can be found by node.
Windows XP - %USERPROFILE%\Application Data\npm\node_modules Windows 7 - %AppData%\npm\node_modules
and then run the command
ls -l
This will give the list of all global node_modules and you can easily see the linked node modules.
sudo brew is no longer an option so if you install with brew at this point you're going to get 2 really obnoxious things: A: it likes to install into /usr/local/opts or according to this, /usr/local/shared. This isn't a big deal at first but i've had issues with node PATH especially when I installed lint. B: you're kind of stuck with sudo commands until you either uninstall and install it this way or you can get the stack from Bitnami
I recommend this method over the stack option because it's ready to go if you have multiple projects. If you go with the premade MEAN stack you'll have to set up virtual hosts in httpd.conf (more of a pain in this stack than XAMPP)plust the usual update your extra/vhosts.conf and /etc/hosts for every additional project, unless you want to repoint and restart your server when you get done updatading things.
참고URL : https://stackoverflow.com/questions/14803978/npm-global-path-prefix
'Programming' 카테고리의 다른 글
| URL 해시 위치 가져 오기 및 jQuery에서 사용 (0) | 2020.06.29 |
|---|---|
| 파일 크기를 확인하는 방법? (0) | 2020.06.29 |
| Python 용 Selenium WebDriver로 페이지가로드 될 때까지 기다리십시오. (0) | 2020.06.29 |
| 자산 디렉토리에서 Webview로드 HTML (0) | 2020.06.29 |
| 64 비트 Windows에서 long의 비트 크기는 얼마입니까? (0) | 2020.06.29 |