Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
MubarakSULAYMAN opened this issue Nov 11, 2018 · 17 comments

Comments

@MubarakSULAYMAN
Copy link

I just reinstalled node and I have been having issues with npm...

C:\Users\Mubarak>node -v
v10.13.0

C:\Users\Mubarak>npm -v
internal/modules/cjs/loader.js:582
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 (internal/modules/cjs/loader.js:580:15)
at Function.Module._load (internal/modules/cjs/loader.js:506:25)
at Function.Module.runMain (internal/modules/cjs/loader.js:741:12)
at startup (internal/bootstrap/node.js:285:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:739:3)
internal/modules/cjs/loader.js:582
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 (internal/modules/cjs/loader.js:580:15)
at Function.Module._load (internal/modules/cjs/loader.js:506:25)
at Function.Module.runMain (internal/modules/cjs/loader.js:741:12)
at startup (internal/bootstrap/node.js:285:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:739:3)

@Hakerh400
Copy link

Related: #1271

@Trott
Copy link
Member

Trott commented Nov 18, 2018

Conflicting versions of Node.js/npm installed? @nodejs/platform-windows

(Transferring to help repo.)

@Trott Trott transferred this issue from nodejs/node Nov 18, 2018
@refack
Copy link

refack commented Nov 18, 2018

Hello @MubarakSULAYMAN, a good place to start is to run where node and where npm. If you find a degenerate node installation, remove it then uninstall and install your desired node version.

@lovelldies
Copy link

Running npm i npm -g does the trick sometimes.

@TerenceSperringerJr
Copy link

TerenceSperringerJr commented Apr 1, 2019

Ah, I had a similar problem with the linux-x64 version v10.15.3 on the Ubuntu subsystem for Windows 10, and suspect it is probably the same problem across multiple platform distributions.
The issue is the scripts for npm and npx aren't even calling the correct files and are also using relative paths incorrectly!

I did the following to fix:

  1. Locate nodejs bin
    Ubuntu Example:
which node
/usr/local/lib/nodejs/node-v10.15.3-linux-x64/bin/node
  1. Navigate to NodeJS bin
    Ubuntu Example:
cd /usr/local/lib/nodejs/node-v10.15.3-linux-x64/bin
  1. View the problematic scripts
    Ubuntu Example:
cat npm
../lib/node_modules/npm/bin/npm-cli.js

cat npx
../lib/node_modules/npm/bin/npx-cli.js
  1. Shake/smack head
    Ubuntu Example:
🤦‍♀️
  1. Rename (or remove) the bad files
    Ubuntu Example:
mv npm npm-wrong

mv npx npx-wrong
  1. Replace bad files with relative symbolic links to the correct locations
    Ubuntu Example:
ln -s ../lib/node_modules/npm/bin/npm npm

ln -s ../lib/node_modules/npm/bin/npx npx
  1. Also add a symbolic link to the node_modules directory itself, because another broken reference occurs without it
    Ubuntu Example:
ln -s ../lib/node_modules/ node_modules
  1. Test
    Ubuntu Example:
cd ../../..

pwd
/usr/local/lib

npm version
{ npm: '6.4.1',
  ares: '1.15.0',
  cldr: '33.1',
  http_parser: '2.8.0',
  icu: '62.1',
  modules: '64',
  napi: '3',
  nghttp2: '1.34.0',
  node: '10.15.3',
  openssl: '1.1.0j',
  tz: '2018e',
  unicode: '11.0',
  uv: '1.23.2',
  v8: '6.8.275.32-node.51',
  zlib: '1.2.11' }
  1. Post about discovery on Github Issue Tracker
    Example:
    Error: Cannot find module 'C:\Program Files\nodejs\node_modules\npm\bin\node_modules\npm\bin\npm-cli.js' #1618 (comment)

@gireeshpunathil
Copy link
Member

ping @MubarakSULAYMAN - is your problem solved?

@gireeshpunathil
Copy link
Member

inactive, closing

@8ctopotamus
Copy link

Updating to the latest version of NPM fixed it for me. npm install npm@latest -g

@suniel26
Copy link

reboot your C:/ drive , worked out for me !

@Andraide
Copy link

In the case you are in Windows Subsystem for Linux, just have to close an re open the terminal.
That work for me.

@hasham7861
Copy link

So I installed the npm and then just reopened it and it worked as well. Thanks to @Andraide

@ghost
Copy link

ghost commented Feb 1, 2020

λ npm i -g create-react-native-app
internal/modules/cjs/loader.js:796
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 (internal/modules/cjs/loader.js:793:17)
at Function.Module._load (internal/modules/cjs/loader.js:686:27)
at Function.Module.runMain (internal/modules/cjs/loader.js:1043:10)
at internal/main/run_main_module.js:17:11 {
code: 'MODULE_NOT_FOUND',
requireStack: []
}
internal/modules/cjs/loader.js:796
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 (internal/modules/cjs/loader.js:793:17)
at Function.Module._load (internal/modules/cjs/loader.js:686:27)
at Function.Module.runMain (internal/modules/cjs/loader.js:1043:10)
at internal/main/run_main_module.js:17:11 {
code: 'MODULE_NOT_FOUND',
requireStack: []
}

can anyone tell me solution

@ndianabasi
Copy link

I'm having this issue too.

internal/modules/cjs/loader.js:1017
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 (internal/modules/cjs/loader.js:1014:15)
at Function.Module._load (internal/modules/cjs/loader.js:884:27)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
at internal/main/run_main_module.js:17:47 {
code: 'MODULE_NOT_FOUND',
requireStack: []
}
internal/modules/cjs/loader.js:1017
throw err;
^

where node

C:\Program Files\nodejs\node.exe

where npm

C:\Users\ndianabasi\npm
C:\Program Files\nodejs\node_modules\npm\bin\npm
C:\Program Files\nodejs\node_modules\npm\bin\npm.cmd
C:\Program Files\nodejs\npm
C:\Program Files\nodejs\npm.cmd
C:\Users\ndianabasi\AppData\Local\Yarn\bin\npm
C:\Users\ndianabasi\AppData\Local\Yarn\bin\npm.cmd

where npx

C:\Program Files\nodejs\node_modules\npm\bin\npx
C:\Program Files\nodejs\node_modules\npm\bin\npx.cmd
C:\Program Files\nodejs\npx
C:\Program Files\nodejs\npx.cmd
C:\Users\ndianabasi\AppData\Local\Yarn\bin\npx
C:\Users\ndianabasi\AppData\Local\Yarn\bin\npx.cmd

Please, how can I solve this?

node --version

v14.0.0

Windows 8.1

@aghos4306
Copy link

Install the latest version of node, make sure that the js file e.g app.js is located inside the created folder that holds the file you want to read

@railsfactory-surekapriya

I hope this will help: https://stackoverflow.com/questions/24721903/npm-cli-js-not-found-when-running-npm

It worked for me when I updated my node path on system variables.

@yougongdeyu
Copy link

I had the same error, and solved it totally, in my case, " v12.18.2\node_modules\npm " not exist, so I
manually add npm which match to v12.18.2 to v12.18.2\node_modules\npm , and open a new terminal, the npm work well.

how can I find the match npm version ?
when you install the node by nvm, it will be logged in the terminal like "Installing npm v6.14.5..".
The content of my terminal is as follows.

C:\windows\system32>nvm install v12.18.2
Downloading node.js version 12.18.2 (64-bit)...
Complete
Downloading npm version 6.14.5... Complete
Installing npm v6.14.5...

The directory structure after the problem is solved is as follows. The nvm is the nvm root path.
nvm\v12.18.2\node_modules\npm\bin\npm-cli.js

@djbrown
Copy link

djbrown commented Apr 23, 2021

My fix was to unset MSYS_NO_PATHCONV in the Git Bash.
The variable is set from my .bashrc in Order for Docker to work properly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests