Npm install not working. Cannot find module npm-cli.js

Can someone help please?

npm install is not working. I’m getting the following error

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

In fact the bin directory under the npm directory is also missing.
I tried installing 2 versions of node (node v 10.16.3 and also 12.13.1), but the problem still exists. Also the full error message is given below:
C:\Program Files\nodejs>npm install
internal/modules/cjs/loader.js:800
throw err;
^

Error: Cannot find module ‘C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js’
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:797:15)
at Function.Module._load (internal/modules/cjs/loader.js:690:27)
at Function.Module.runMain (internal/modules/cjs/loader.js:1047:10)
at internal/main/run_main_module.js:17:11 {
code: ‘MODULE_NOT_FOUND’,
requireStack:
}
internal/modules/cjs/loader.js:800
throw err;
^

Error: Cannot find module ‘C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js’
e[90m at Function.Module._resolveFilename (internal/modules/cjs/loader.js:797:15)e[39m
e[90m at Function.Module._load (internal/modules/cjs/loader.js:690:27)e[39m
e[90m at Function.Module.runMain (internal/modules/cjs/loader.js:1047:10)e[39m
e[90m at internal/main/run_main_module.js:17:11e[39m {
code: e[32m’MODULE_NOT_FOUND’e[39m,
requireStack:
}

You need to run this command from inside the mflix-js directory which you might have downloaded from the Handouts section.

Kanika

Thank you Kanika. The npm install problem was fixed as you advised, by running it inside the mflix directory. Now there is another problem with npm start. Let me work on that before I can get back to you.
Also sorry for the delay in getting back to you. I live in Central New Jersey, USA and you live in India, so we’re almost half a day apart.
Thanking you,
Sincerely,
Charles

1 Like

Thats not a problem @charles_89592! :slight_smile: Just let me know whenever you have any issue.

Kanika

npm start still has problems. This is the output I’m getting and the program is just hanging and the app has crashed.

C:\Program Files\nodejs\mflix-js>npm start

server@1.0.0 start C:\Program Files\nodejs\mflix-js
nodemon -L ./index.js

[nodemon] 1.19.1
[nodemon] to restart at any time, enter rs
[nodemon] watching: .
[nodemon] starting node ./index.js
MongoParseError: Invalid connection string
at parseConnectionString (C:\Program Files\nodejs\mflix-js\node_modules\mongodb\lib\core\uri_parser.js:507:21)
at connect (C:\Program Files\nodejs\mflix-js\node_modules\mongodb\lib\operations\connect.js:266:3)
at ConnectOperation.execute (C:\Program Files\nodejs\mflix-js\node_modules\mongodb\lib\operations\connect.js:191:5)
at C:\Program Files\nodejs\mflix-js\node_modules\mongodb\lib\operations\execute_operation.js:109:26
at new Promise ()
at executeOperation (C:\Program Files\nodejs\mflix-js\node_modules\mongodb\lib\operations\execute_operation.js:102:10)
at MongoClient.connect (C:\Program Files\nodejs\mflix-js\node_modules\mongodb\lib\mongo_client.js:216:10)
at Function.MongoClient.connect (C:\Program Files\nodejs\mflix-js\node_modules\mongodb\lib\mongo_client.js:379:22)
at Object.connect (C:\Program Files\nodejs\mflix-js\src/index.js:23:13)
at Module._compile (internal/modules/cjs/loader.js:959:30)
[nodemon] app crashed - waiting for file changes before starting…

Please check the uri string in .env file.

Kanika

Sorry for piggybacking but when I try to post a new topic I get an error popup saying it cannot create a tag for the post. This seems to be the only way to ask my question.

I don’t know why zsh can’t find npm. See screenshot below:

I tried checking the path and I had to do some kind of fancy footwork to install the mongo shell previously when I took the M001 course, now I wonder if that’s causing me problems. I don’t recall what I did in the first place, unfortunately. I am pretty new to all this. Here’s another screenshot in case it’s helpful:

Using Mac Catalina.

Let see the content of /usr/local/share/npm/bin.

Screen Shot 2020-10-06 at 2.34.27 PM
Screen Shot 2020-10-06 at 2.34.55 PM

I am not sure what you are asking for…

Screen Shot 2020-10-06 at 2.41.07 PM


Here’s a cloudshare of my hidden folders if that information helps troubleshoot at all…

You are specifying /usr/local/share/npm/bin in your path but this directory does not exist as seen in one of your screenshot. That is why npm is not found. You have to specify the directory where npm resides.