programing

설치 후 Gulp 명령을 찾을 수 없음

nasanasas 2020. 9. 2. 18:52
반응형

설치 후 Gulp 명령을 찾을 수 없음


나는 gulp (globally)를 설치했고 다음 코드를 실행했기 때문에 작동하는 것처럼 보입니다.

├── tildify@0.2.0
├── interpret@0.3.5
├── pretty-hrtime@0.2.1
├── deprecated@0.0.1
├── archy@0.0.2
├── minimist@0.2.0
├── semver@2.3.2
├── orchestrator@0.3.7 (stream-consume@0.1.0, sequencify@0.0.7, end-of-stream@0.1.5)
├── chalk@0.5.1 (escape-string-regexp@1.0.1, ansi-styles@1.1.0, supports-color@0.2.0, strip-ansi@0.3.0, has-ansi@0.1.0)
├── gulp-util@2.2.20 (lodash._reinterpolate@2.4.1, dateformat@1.0.8-1.2.3, vinyl@0.2.3, through2@0.5.1, multipipe@0.1.1, lodash.template@2.4.1)
├── liftoff@0.12.0 (extend@1.2.1, minimist@0.1.0, resolve@0.7.4, findup-sync@0.1.3)
└── vinyl-fs@0.3.5 (graceful-fs@3.0.2, lodash@2.4.1, mkdirp@0.5.0, strip-bom@0.3.1, vinyl@0.2.3, through2@0.5.1, glob-watcher@0.0.6, glob-stream@3.1.14)

하지만 내가 타이핑 gulp하면-bash: gulp: command not found

무슨 일인지 아십니까?


npm이 잘못된 디렉토리에 설치되었으므로이 코드를 실행하여 "npm config prefix"를 변경해야했습니다.

npm config set prefix /usr/local

그런 다음 전역 적으로 (-g 매개 변수를 사용하여) gulp를 다시 설치했으며 제대로 작동했습니다.

이 기사에서 해결책을 찾은 곳 : http://webbb.be/blog/command-not-found-node-npm


질문이 왜 반대 투표인지 확실하지 않지만 동일한 문제가 있었고 블로그 게시물에 따라 문제 해결을 권장했습니다. 내가 추가해야 할 한 가지는 내 경우에 한 번 실행되었다는 것입니다.

npm config set prefix /usr/local

나는이 확인 npm root -g가리키는했다 /usr/local/lib/node_modules/npm, 그러나 설치하기 위해 gulp/usr/local/lib/node_modules, 내가 사용했다 sudo:

sudo npm install gulp -g


당신이 사용하는 경우 tcsh(맥 OS X에 대한 내 기본 쉘 인), 당신은 아마 입력해야 rehash바로 설치 완료 후 껍질로 :

npm install -g gulp

바로 뒤에 :

rehash

그렇지 않으면을 처음 설치하는 gulp경우 셸이 새 실행 파일이 설치된 것을 인식하지 못할 수 있으므로 새 셸을 시작하거나 rehash현재 셸을 입력해야합니다 .

(기본적으로 전역 적으로 설치하는 각 명령에 대해 한 번만 수행됩니다.)


나는 이것이 오래된 스레드라는 것을 알고 있지만 Future-Me와 후손을 위해 "running npm as sudo"토론에 2 센트를 추가해야한다고 생각했습니다. 면책 조항 : Windows를 사용하지 않습니다. 이러한 단계는 Windows가 아닌 컴퓨터 (가상 및 물리적)에서만 입증되었습니다.

권한을 npm의 기본 디렉토리로 변경하면 sudo를 사용할 필요가 없습니다.


방법 :없이 npm을 실행하기 위해 권한 변경 sudo

1 단계 : npm의 기본 디렉토리가 어디에 있는지 확인합니다.

  • 이렇게하려면 터미널을 열고 다음을 실행하십시오.
    npm config get prefix

2 단계 : 해당 명령의 출력에 따라 진행합니다.

  • 시나리오 1 : npm의 기본 디렉토리는 /usr/local
    대부분의 사용자에게 npm의 기본 디렉토리가 / usr / local로 표시됩니다.이 경우 4 단계로 건너 뛰어 디렉토리에 대한 권한을 업데이트 할 수 있습니다.
  • 시나리오 2 : npm의 기본 디렉토리는 /usror /Users/YOURUSERNAME/node_modulesor /Something/Else/FishyLooking
    입니다. npm의 기본 디렉토리가 / usr / local이 아니라 설명 할 수 없거나 이상해 보이는 경우 3 단계로 이동하여 npm의 기본 디렉토리를 변경해야합니다. 또는 훨씬 더 큰 규모로 권한엉망으로 만들 위험이 있습니다 .

3 단계 : npm의 기본 디렉토리 변경 :

  • 전역 설치를 위해 특별히 디렉토리를 만든 다음 해당 디렉토리를 $ PATH에 추가하는 등 몇 가지 방법이 있지만 / usr / local이 이미 경로에 있으므로 npm을 변경하는 것이 더 간단하다고 생각합니다. 기본 디렉토리입니다. 이렇게 :npm config set prefix /usr/local
    • 내가 언급 한 다른 접근 방식에 대한 자세한 내용은 여기 에서 npm 문서를 참조 하세요 .

4 단계 : npm의 기본 디렉터리에 대한 권한을 업데이트합니다.

  • npm의 기본 디렉토리가 적절한 위치에 있음을 확인한 후 다음 명령을 사용하여 권한을 업데이트 할 수 있습니다.
    sudo chown -R $(whoami) $(npm config get prefix)/{lib/node_modules,bin,share}

지금 당신은 실행할 수 있어야 npm <whatever>하지 sudo. 참고 : 이러한 변경 사항을 적용하려면 터미널을 다시 시작해야 할 수 있습니다.


비슷한 문제가 있었는데 다음 단계를 수행했는데 작동했습니다 .Mac 터미널로 이동하여 명령을 실행하십시오.

1. npm 구성 세트 접두사 / usr / local

2. sudo chown -R $ (whoami) $ (npm config get prefix) / {lib / node_modules, bin, share}

이 두 명령은 npm 경로를 올바르게 설정하므로 더 이상 npm에서 sudo를 사용할 필요가 없습니다. 다음 꿀꺽 꿀꺽 꿀꺽 제거

  1. npm 제거 gulp

  2. sudo없이 다시 gulp 설치, npm install gulp -g

작동합니다 !!


I had this problem with getting "command not found" after install but I was installed into /usr/local as described in the solution above.

My problem seemed to be caused by me running the install with sudo. I did the following.

  1. Removing gulp again with sudo
  2. Changing the owner of /usr/local/lib/node_modules to my user
  3. Installing gulp again without sudo. "npm install gulp -g"

You need to do this npm install --global gulp. It works for me and i also had this problem. It because you didn't install globally this package.


In my case adding sudo before npm install solved gulp command not found problem

sudo npm install


If you want to leave your prefix intact, just export it's bin dir to your PATH variable:
export PATH=$HOME/your-path/bin:$PATH
I added this line to my $HOME/.profile and sourced it.

Setting prefix to /usr/local makes you use sudo, so I like to have it in my user dir. You can check your prefix with npm prefix -g.


I got this working on Win10 using a combination of the answers from above and elsewhere. Posting here for others and future me.

I followed the instructions from here: https://gulpjs.com/docs/en/getting-started/quick-start but on the last step after typing gulp --version I got the message -bash: gulp: command not found

To fix this:

  1. I added %AppData%\npm to my Path environment variable
  2. Closed all gitbash (cmd, powershell, etc...) and restarted gitbash.
  3. Then gulp --version worked

Also, found the below for reasons why not to install gulp globally and how to remove it (not sure if this is advisable though):

what does gulp-"cli" stands for?

How to uninstall Gulp CLI from NPM globally?

참고URL : https://stackoverflow.com/questions/25090452/gulp-command-not-found-after-install

반응형