Programing

npm을 실행할 때 npm-cli.js를 찾을 수 없음

lottogame 2020. 10. 23. 07:28
반응형

npm을 실행할 때 npm-cli.js를 찾을 수 없음


보통은 npm을 이용해서 라이브러리를 설치할 수 있지만 오늘은 여만을 설치할 때 이런 오류가 발생했습니다. 근본 원인을 파악하는 데 도움을주세요.

D:\Works\phonegap\ionic\todo>npm install -g yo
    module.js:340
    throw err;
          ^
Error: Cannot find module 'C:\Program Files\nodejs\node_modules\npm\bin\node_modules\npm\bin\npm-cli.js'

at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Function.Module.runMain (module.js:497:10)
at startup (node.js:119:16)
at node.js:906:3

폴더를 살펴 보았습니다.

C : \ Program Files \ nodejs \ node_modules \ npm \ bin \

그러나 설명 된 오류로 node_modules 폴더 가 표시되지 않습니다 .

나는 또한 npm-cli.js 를 찾고 그것이 실제로C:\Program Files\nodejs\node_modules\npm\bin\


문제는 시스템 변수에서 노드의 잘못된 경로로 인한 것으로 밝혀졌습니다. 경로가 현재 가리키는

(정말 언제 수정했는지 모르겠습니다)

C:\Program Files\nodejs\node_modules\npm\bin

그래서 나는

C:\Program Files\nodejs

그리고 그것은 매력처럼 작동합니다.


명령 줄에서 실행해야합니다.

SET PATH=C:\Program Files\Nodejs;%PATH%

경로에 당신이 가지고있는 경우에도이 문제가있을 수 있습니다 C:\Program Files\nodejsC:\Program Files\nodejs\node_modules\npm\bin. 경로에서 후자를 제거하십시오.


npm설치된 노드 경로에서 이름이 지정된 디렉토리를 복사합니다 (내 경우에는 npm 디렉토리를에서 사용할 수 있음 C:\Program Files\nodejs\node_modules).

C:\Users\%USERNAME%\AppData\Roaming\npm\node_modules복사 한 npm디렉토리 찾아 붙여 넣 습니다.

이 방법은 동일한 오류가 발생했을 때 저에게 효과적이었습니다. . .


이것은 질문에서와 같은 경우는 아니지만 유사한 문제에 직면 한 사람에게 도움이 될 수 있습니다. Windows npm에서 일부 CI / 자동화 도구에서 명령을 호출하는 경우 다음 오류가 발생할 수 있습니다.

Error: Cannot find module 'SOME_PATH\node_modules\npm\bin\npm-cli.js'

어디 SOME_PATH하지 않습니다 Program Files/...하지만 일부 프로젝트 디렉토리 대신. 따라서 npm은 .NET에서 검색하는 대신 프로젝트 루트 디렉터리에서 npm-cli.js를 찾으려고합니다 Program Files/nodejs.

그 이유는 npm.cmd 스크립트입니다.

:: Created by npm, please don't edit manually.
@ECHO OFF

SETLOCAL

SET "NODE_EXE=%~dp0\node.exe"
IF NOT EXIST "%NODE_EXE%" (
  SET "NODE_EXE=node"
)


SET "NPM_CLI_JS=%~dp0\node_modules\npm\bin\npm-cli.js"
FOR /F "delims=" %%F IN ('CALL "%NODE_EXE%" "%NPM_CLI_JS%" prefix -g') DO (
  SET "NPM_PREFIX_NPM_CLI_JS=%%F\node_modules\npm\bin\npm-cli.js"
)
IF EXIST "%NPM_PREFIX_NPM_CLI_JS%" (
  SET "NPM_CLI_JS=%NPM_PREFIX_NPM_CLI_JS%"
)

"%NODE_EXE%" "%NPM_CLI_JS%" %*

이 스크립트는 %~dp0npm-cli.js를 조회하는 데 사용 하지만 일부 자동화 도구 %~dp0는 스크립트가 잘못 작동하도록 로컬 프로젝트 디렉토리 가리키는 방식으로 작업 디렉토리를 설정할 수 있습니다.

한 가지 가능한 해결책은 이것에서 npm 호출을 변경하는 것입니다.

npm.cmd install

이에

cmd.exe /c npm.cmd install

방금 NodeJS 설치를 수리했는데 저에게 효과적이었습니다!

Control Panel\All Control Panel Items\Programs and Features->로 이동하여 NodeJS수리 옵션을 찾아 선택하십시오. 도움이 되었기를 바랍니다.


다른 답변 중 어느 것도 나를 위해 일하지 않았습니다.

내가 쓴 내용은 다음과 같습니다 (windows의 git bash shell).

PATH="/c/Program Files/nodejs/:$PATH" npm run yeoman

Mac에서 :

동일한 오류가 발생했을 때 Maven com.github.eirslett Frontend Plugin에서 이것을 실행했습니다.

결국 나는 :

여기에서 설치 프로그램 다운로드를 통해 Node.js를 설치합니다. http://nodejs.org/

내 maven 빌드 구조 내에서 모든 node/node_modules/폴더를 삭제하십시오 .


nvm과 함께 설치할 때 노드 8.5에서 동일한 문제가 발생했습니다. 아래 솔루션이 저에게 효과적이었습니다.

$ nvm uninstall 8.5
8.5.0
Uninstalling node v8.5.0...Error removing node v8.5.0
Manually remove C:\Users\Omkar\AppData\Roaming\nvm\v8.5.0.

$ nvm install 8.5
8.5.0
Downloading node.js version 8.5.0 (64-bit)...
Complete
Creating C:\Users\Omkar\AppData\Roaming\nvm\temp

Downloading npm version 5.3.0... Complete
Installing npm v5.3.0...

Installation complete. If you want to use this version, type

nvm use 8.5.0

Omkar@VAST-0137 MINGW64 /d/code

이것은 노드 8.5가 이전에 nvm으로 올바르게 설치되지 않았기 때문에 나를 위해 일했습니다. "npm \ bin \ npm-cli.js"폴더와 파일이 이전에 node_modules 내에 생성되지 않은 원인을 알아 냈습니다.


환경 변수를 변경하지 마십시오.

문제를 일으킨 설치 프로그램이었고 필요한 모든 파일을 설치하지 않았습니다.

방금 Windows 7에서 NODEJS 설정을 복구했으며 매우 잘 작동합니다. 무언가가 작동하지 않는 경우를 대비하여 다시 설치할 수 있습니다.


이것은 GoogleChrome / puppeteer를 설치 한 후 나에게 발생하기 시작 했으며 해결책은 npm을 다시 설치하는 것이 었습니다.

$ npm i npm@latest

또는

$ npm install npm@latest

위의 것 외에도 제거해야했습니다 C:\Users\%USERNAME%\AppData\Roaming\npm. 이것은 도움이되었습니다.


There are actually 2 paths which was added to your System's Variable when upgrading to nodejs latest version.
1. C:\Program Files\nodejs
2. C:\Program Files\nodejs\node_modules\npm\bin
For windows 7/8/8.1 users, they will not have an Environment Variables Windows 10 smart GUI.
Anyway, all you have to do is search for "C:\Program Files\nodejs\node_modules\npm\bin" and remove it.
Also, remove "C:\Users\%USERNAME%\AppData\Roaming\npm" from your environment variables. I am posting this answer because I wasted my 10hrs searching for the solution on internet. By combining the above answer I finally make it through the problem.


just run this command :

npm i npm@latest -g

I had the same issue on windows. I just repaired Node and it worked fine after a restart of the command on windows.


npm install -g npm@[version] fixed the problem


Solution for me in VS2017 (Under Tools | Options ... )

Under Tools | Options ...

I changed the path to: C:\Program Files\nodejs


I run into this problem when installing node9.0.0 on windows7 at the end the solution was to just remove npm npm.cmd npx npx.cmd from C:\Program Files\nodejs\node_modules\npm\bin before doing this a workaround was to run C:\Program Files\nodejs\npm so that is one way so see if you have the same problem I had.


create a npm folder manually inside node_modules and rerun the installer with repair options. It copies the missing files.


None of the solutions here worked for me but after I restarted my system and did npm install again, it worked. I would guess one or more processes I ran before held unto it.

Simple PC restart on Windows 10 did the magic for me!


In my case, I was using nvm-windows 1.1.6 , and I updated my nodejs version using nvm install latest, which eventually told me that nodejs and npm are installed, however when I tried to do npm install, I received

Error: Cannot find module 'C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js'

upon checking nvm-windows structure, I found that C:\Program Files\nodejs was symlinked to %APPDATA%\nvm\NODE_VERSION, (NODE_VERSION was v9.7.1 in my case) which has the folder node_modules having nothing inside, caused this error. The solution was to copy the npm folder from one of my previous versions' node_modules folder and paste it in. I then updated my npm with npm install npm@next -g and everything started working again.


For me none of the above worked, I just noticed that every time I do a "npm install..." any npm command just stop working. So every install I do, I have to run the NodeJS installation programme and select "repair". Until I find a real solution :)


Updating NPM to the latest version worked for me:

npm install npm@latest -g

for guys still coming around this thread...

  • install node from official site (check npm and node version to check whether installed properly, yes in a new terminal/cmd),
  • install nvm now and when prompt to whether manage current node with nvm click yes.
  • open new cmd and run nvm on.

Done. easy way.


Change the environment path variable C:\Program Files\nodejs\node_modules\npm\bin and open the command terminal and npm -v and


On Windows 10:

  1. Press windows key, type edit the system environment variables then enter.
  2. Click environment variables...
  3. On the lower half of the window that opened with title Environment Variables there you will see a table titled System Variables, with two columns, the first one titled variable.
  4. Find the row with variable Path and click it.
  5. Click edit which will open a window titled Edit evironment variable.
  6. Here if you find

C:\Program Files\nodejs\node_modules\npm\bin

select it, and click edit button to your right, then edit the field to the path where you have the nodejs folder, in my case it was just shortening it to :

C:\Program Files\nodejs

Then I closed all my cmd or powershell terminals, opened them again and npm was working.

참고URL : https://stackoverflow.com/questions/24721903/npm-cli-js-not-found-when-running-npm

반응형