Development Tip

karma가 이미 설치된 경우 karma 명령을 찾을 수 없습니다.

yourdevel 2020. 11. 2. 19:51
반응형

karma가 이미 설치된 경우 karma 명령을 찾을 수 없습니다.


karma를 설치하기 위해 node.js를 사용했습니다. 터미널에서 다음 명령을 실행할 때 첫 번째 시도가 실패했습니다.

npm install -g karma

실패했기 때문에 다음을 사용하기로 결정했습니다.

sudo npm install -g karma

내 비밀번호를 입력 한 후 올바르게 설치되는 것 같습니다. 설치 출력의 일부를 붙여넣고 있습니다. 누군가에게 의미가 있고 내 질문과 관련이있을 수도 있습니다. 모든 npm http 메시지 후에 이것은 내가 보는 것입니다.

> ws@0.4.27 install /usr/local/share/npm/lib/node_modules/karma/node_modules/socket.io/node_modules/socket.io-client/node_modules/ws
> (node-gyp rebuild 2> builderror.log) || (exit 0)

  CXX(target) Release/obj.target/bufferutil/src/bufferutil.o
  SOLINK_MODULE(target) Release/bufferutil.node
  SOLINK_MODULE(target) Release/bufferutil.node: Finished
  CXX(target) Release/obj.target/validation/src/validation.o
  SOLINK_MODULE(target) Release/validation.node
  SOLINK_MODULE(target) Release/validation.node: Finished
/usr/local/share/npm/bin/karma -> /usr/local/share/npm/lib/node_modules/karma/bin/karma
karma@0.8.6 /usr/local/share/npm/lib/node_modules/karma
├── pause@0.0.1
├── dateformat@1.0.2-1.2.3
├── xmlbuilder@0.4.2
├── colors@0.6.0-1
├── chokidar@0.6.2
├── growly@1.1.1
├── mime@1.2.9
├── q@0.9.6
├── rimraf@2.1.4 (graceful-fs@1.2.3)
├── coffee-script@1.6.3
├── minimatch@0.2.12 (sigmund@1.0.0, lru-cache@2.3.0)
├── optimist@0.3.5 (wordwrap@0.0.2)
├── glob@3.1.21 (inherits@1.0.0, graceful-fs@1.2.3)
├── LiveScript@1.0.1 (prelude-ls@1.0.1)
├── log4js@0.6.6 (dequeue@1.0.3, semver@1.1.4, async@0.1.15, readable-stream@1.0.2)
├── lodash@1.1.1
├── http-proxy@0.10.3 (pkginfo@0.2.3, utile@0.1.7)
├── istanbul@0.1.22 (abbrev@1.0.4, which@1.0.5, fileset@0.1.5, nopt@2.0.0, wordwrap@0.0.2, async@0.1.22, mkdirp@0.3.5, esprima@0.9.9, escodegen@0.0.24, handlebars@1.0.12)
└── socket.io@0.9.16 (base64id@0.1.0, policyfile@0.0.4, redis@0.7.3, socket.io-client@0.9.16)

그런 다음 다음 명령을 실행하여이 명령으로 karma 구성 파일을 만들려고 할 때 :

karma init karma.config.js

다음은 반환되는 메시지입니다.

-bash: karma: command not found

이전에 sudo로 동일한 명령을 시도했지만 동일한 결과를 얻습니다.

무슨 일이 일어나고 있는지 아는 사람이 있습니까? 도움을 주시면 감사하겠습니다.

*최신 정보! /usr/local/share/npm/lib/node_modules/karma/node_modules/socket.io/node_modules/socket.io-client/node_modules/ws에있는 builderror.log라는 파일을 확인하기로 결정했습니다.

이것이 보여주는 것입니다.

gyp WARN EACCES user "root" does not have permission to access the dev dir "/Users/eperez/.node-gyp/0.10.5"
gyp WARN EACCES attempting to reinstall using temporary dev dir "/usr/local/share/npm/lib/node_modules/karma/node_modules/socket.io/node_modules/socket.io-client/node_modules/ws/.node-gyp"
gyp http GET http://nodejs.org/dist/v0.10.5/node-v0.10.5.tar.gz
gyp http 200 http://nodejs.org/dist/v0.10.5/node-v0.10.5.tar.gz

@mayankcpdixit 은 OP의 원래 질문에 대한 응답으로 답변을 제공했지만 누군가가 그것을 놓칠 경우를 대비하여 여기에 다시 넣을 것입니다.

모든 것을 제거 할 필요는 없으며 설치하려고하는 모든 npm 패키지에 대해 수동으로 새 경로 링크를 추가해야한다면 아마도 직접 촬영할 것입니다.

npm install -g karma-cli

팔. 이제 karma 명령 줄이 설치되었습니다. 그런트처럼.


편집 : @mayankcpdixit찬성 하는 것을 잊지 마세요 . 그는 원래 게시물에 직접 댓글을 달았지만 실제로 질문에 "답변"하지는 않았습니다.


In your ~/.bash_profile (or similar) amend your PATH to include npm-installed binaries:

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

I had this very same issue, and found this solution to be less time-consuming and impactful than completely re-installing node.

EDIT this has also worked for others in bash_profile

export PATH="$PATH:/usr/local/lib/node_modules/karma/bin" 

It is recommended to install karma with its Command-Line-Interface (karma-cli) which will take care of fetching the appropriate karma. You can also install a different local version specific to each project you're working on and karma-cli will pick the appropriate one.

From the karma installation page:

Typing ./node_modules/karma/bin/karma start sucks so you might find it useful to install karma-cli globally:

npm install -g karma-cli

Now, check that karma was installed by typing:

karma start

You can also check that karma was installed by going to this directory:

cd /usr/local/lib/node_modules/karma

Good luck!


Don't need to completely uninstall node.js

Just

sudo rm -rf /usr/local/lib/node_modules/npm/

Then
install node.js

Then
reinstall karma

This worked for me.


I had to add export PATH="$PATH":/usr/local/lib/node_modules/npm/node_modules/karma/bin after installing karma with sudo npm install karma.

hope this helps.


Just go to test.sh:

Find: $BASE_DIR/../node_modules/karma/bin/karma start $BASE_DIR/../config/karma.conf.js $*

Replace with: /usr/local/bin/karma start $BASE_DIR/../config/karma.conf.js $*

Or: karma start $BASE_DIR/../config/karma.conf.js $*


I was also facing the same issue. It looks like karma for command line is a separate package which can be installed by

npm install -g karma-cli


When upgrading from Karma 0.10 to 0.12 the link to the karma executable is removed.

You can get it back with

cd node_modules/.bin
ln -s ../karma/bin/karma karma

Try re-installing node.js. There are lots of ways to install it, but I recommend downloading from nodejs.org

If that doesn't work, you may try to re-install karma.

참고URL : https://stackoverflow.com/questions/17704106/karma-command-not-found-when-karma-already-installed

반응형