Error While doing npm install

Hi everyone.
I was executing npm install (windows 10) from Visual Code and I’ve got this message:

**PS C:\Users\Renato\Dev\Cursos\mongodb\m220js> npm install

weak-napi@1.0.3 install C:\Users\Renato\Dev\Cursos\mongodb\m220js\node_modules\weak-napi
node-gyp rebuild

C:\Users\Renato\Dev\Cursos\mongodb\m220js\node_modules\weak-napi>if not defined npm_config_node_gyp (node “C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin\…\node_modules\node-gyp\bin\node-gyp.js” rebuild ) else (node “C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js” rebuild )
gyp ERR! find VS
gyp ERR! find VS msvs_version not set from command line or npm config
gyp ERR! find VS VCINSTALLDIR not set, not running in VS Command Prompt
gyp ERR! find VS checking VS2017 (15.8.28010.2003) found at:
gyp ERR! find VS “C:\Program Files (x86)\Microsoft Visual Studio\2017\Community”
gyp ERR! find VS - “Visual Studio C++ core features” missing
gyp ERR! find VS could not find a version of Visual Studio 2017 or newer to use
gyp ERR! find VS looking for Visual Studio 2015
gyp ERR! find VS - not found
gyp ERR! find VS not looking for VS2013 as it is only supported up to Node.js 8
gyp ERR! find VS
gyp ERR! find VS **************************************************************
gyp ERR! find VS You need to install the latest version of Visual Studio
gyp ERR! find VS including the “Desktop development with C++” workload.
gyp ERR! find VS For more information consult the documentation at:
gyp ERR! find VS https://github.com/nodejs/node-gyp#on-windows
gyp ERR! find VS **************************************************************
gyp ERR! find VS
gyp ERR! configure error
gyp ERR! stack Error: Could not find any Visual Studio installation to use
gyp ERR! stack at VisualStudioFinder.fail (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:121:47)
gyp ERR! stack at C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:74:16
gyp ERR! stack at VisualStudioFinder.findVisualStudio2013 (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:344:14)
gyp ERR! stack at C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:70:14
gyp ERR! stack at C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:365:16
gyp ERR! stack at C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\util.js:54:7
gyp ERR! stack at C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\util.js:33:16
gyp ERR! stack at ChildProcess.exithandler (child_process.js:302:5)
gyp ERR! stack at ChildProcess.emit (events.js:209:13)
gyp ERR! stack at maybeClose (internal/child_process.js:1021:16)
gyp ERR! System Windows_NT 10.0.18362
gyp ERR! command “C:\Program Files\nodejs\node.exe” “C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js” “rebuild”
gyp ERR! cwd C:\Users\Renato\Dev\Cursos\mongodb\m220js\node_modules\weak-napi
gyp ERR! node -v v12.10.0
gyp ERR! node-gyp -v v5.0.3
gyp ERR! not ok
npm WARN eslint-config-react-app@2.1.0 requires a peer of babel-eslint@^7.2.3 but none is installed. You must install peer dependencies yourself.
npm WARN eslint-config-react-app@2.1.0 requires a peer of eslint-plugin-jsx-a11y@^5.1.1 but none is installed. You must install peer dependencies yourself.
npm WARN server@1.0.0 No repository field.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.9 (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.9: wanted {“os”:“darwin”,“arch”:“any”} (current: {“os”:“win32”,“arch”:“x64”})

npm ERR! Maximum call stack size exceeded

npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Renato\AppData\Roaming\npm-cache_logs\2019-10-16T01_04_10_079Z-debug.log
PS C:\Users\Renato\Dev\Cursos\mongodb\m220js>**

So, what should I do?

Hi @Renato_67929,

This is a known error and it will not halt any process. Try running npm start and it should be able to start the server.

Let me know if it doesn’t work.

Kanika

Hi Kanika, it worked fine.

Thanks for you support.

On a second thought, it didn’t work:

C:\Users\Renato\Dev\Cursos\mongodb\m220js>npm start

server@1.0.0 start C:\Users\Renato\Dev\Cursos\mongodb\m220js
nodemon -L ./index.js

[nodemon] 1.19.1
[nodemon] to restart at any time, enter rs
[nodemon] watching: .
[nodemon] starting node ./index.js
MongoParseError: URI malformed, cannot be parsed
at parseConnectionString (C:\Users\Renato\Dev\Cursos\mongodb\m220js\node_modules\mongodb\lib\core\uri_parser.js:502:21)
at connect (C:\Users\Renato\Dev\Cursos\mongodb\m220js\node_modules\mongodb\lib\operations\connect.js:266:3)
at ConnectOperation.execute (C:\Users\Renato\Dev\Cursos\mongodb\m220js\node_modules\mongodb\lib\operations\connect.js:191:5)
at C:\Users\Renato\Dev\Cursos\mongodb\m220js\node_modules\mongodb\lib\operations\execute_operation.js:109:26
at new Promise ()
at executeOperation (C:\Users\Renato\Dev\Cursos\mongodb\m220js\node_modules\mongodb\lib\operations\execute_operation.js:102:10)
at MongoClient.connect (C:\Users\Renato\Dev\Cursos\mongodb\m220js\node_modules\mongodb\lib\mongo_client.js:216:10)
at Function.MongoClient.connect (C:\Users\Renato\Dev\Cursos\mongodb\m220js\node_modules\mongodb\lib\mongo_client.js:379:22)
at Object.connect (C:\Users\Renato\Dev\Cursos\mongodb\m220js\src/index.js:23:13)
at Module._compile (internal/modules/cjs/loader.js:936:30)

Summary

This text will be hidden

[nodemon] app crashed - waiting for file changes before starting…

You need to check the mongodb URI in configuration file .env.

Kanika

I don’t know what can I do in this case. Is there any documentation or instructions for that?

Sure. In the README lecture, under the " Running the Application" topic:

  • You need to copy your atlas connection string and paste in the respective dotenv file
  • rename the dotenv file to .env file.

If you are unable to solve the issue, please share the contents of the .env file here. :slight_smile:

Kanika

Hi Kanika, I have the same error…

Ticket: Connection

Rename this file to .env after filling in your MFLIX_DB_URI and your SECRET_KEY

Do not surround the URI with quotes

SECRET_KEY=newSecretKey
MFLIX_DB_URI=mongodb+srv://m220student:m220password@mflix-pqirr.mongodb.net/test
MFLIX_NS=sample_mflix
PORT=5000

what am I doing wrong?
thanks
Damiano

Hi @Damiano_49342,

It is showing me below error when trying to connect using the string in your .env file. Please check the username and password and try again.

   AuthenticationFailed: bad auth Authentication failed. :

If not resolved, then you can recreate the user. :slight_smile:

Kanika

Hi Kanika, I changed the user’s password otherwise everyone can access to it :slight_smile:
anyway the password is “m220psw”.

anyway the error messages are the same as per this Renato’s message: Error While doing npm install

Thanks Damiano

MongoParseError: URI malformed, cannot be parsed

This error usually occurs when URI is incorrect or quotes are involved. But that seems good in your case. I am sure you have checked all these points, but can you double check:

  • Is the file renamed to .env. You need to copy string in both places. Under [PROD] as well as [TEST] keys.

Kanika

Hi @kanikasingla

I’ve renamed the file dotenv_win to dotenv_win.env because I am on a Win system.
I’ve changed it as per my previous message (in a nutshell I have added the connection string to the constant MFLIX_DB_URI and changed my SECRET_KEY) as per Chapter 1 “Lecture: README”.

I could not find [PROD] nor [TEST] keys into the README file though, so… What do you mean with “Under [PROD] as well as [TEST] keys”?

Damiano

This should be just “.env” file.

Sorry about this confusion. This was for OS other than windows.

Kanika

1 Like

OMG :slight_smile: I have added the extension instead of rename it :slight_smile: I am gonna try that as soon as I get back home.

Thanks for your help

Damiano

1 Like

No issues :slight_smile: Let me know if it works.

Kanika

Confirmed! it works now :smiley: thanks again!

Damiano

1 Like