Npm install errors

I am getting errors when running npm install,
ryancourtney@Ryans-MacBook-Air-8 mflix-js % npm install

weak-napi@1.0.3 install /Users/ryancourtney/Desktop/mflix-js/node_modules/weak-napi
node-gyp rebuild

xcode-select: error: tool ‘xcodebuild’ requires Xcode, but active developer directory ‘/Library/Developer/CommandLineTools’ is a command line tools instance

xcode-select: error: tool ‘xcodebuild’ requires Xcode, but active developer directory ‘/Library/Developer/CommandLineTools’ is a command line tools instance

Traceback (most recent call last):
File “/usr/local/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py”, line 16, in
sys.exit(gyp.script_main())
File “/usr/local/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/init.py”, line 545, in script_main
return main(sys.argv[1:])
File “/usr/local/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/init.py”, line 538, in main
return gyp_main(args)
File “/usr/local/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/init.py”, line 523, in gyp_main
generator.GenerateOutput(flat_list, targets, data, params)
File “/usr/local/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/generator/make.py”, line 2170, in GenerateOutput
part_of_all=qualified_target in needed_targets)
File “/usr/local/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/generator/make.py”, line 795, in Write
self.Pchify))
File “/usr/local/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/generator/make.py”, line 1190, in WriteSources
cflags = self.xcode_settings.GetCflags(configname)
File “/usr/local/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/xcode_emulation.py”, line 551, in GetCflags
archs = self.GetActiveArchs(self.configname)
File “/usr/local/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/xcode_emulation.py”, line 420, in GetActiveArchs
xcode_archs_default = GetXcodeArchsDefault()
File “/usr/local/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/xcode_emulation.py”, line 118, in GetXcodeArchsDefault
xcode_version, _ = XcodeVersion()
File “/usr/local/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/xcode_emulation.py”, line 1265, in XcodeVersion
version = re.match(r’(\d.\d.?\d*)’, version).groups()[0]
AttributeError: ‘NoneType’ object has no attribute ‘groups’
gyp ERR! configure error
gyp ERR! stack Error: gyp failed with exit code: 1
gyp ERR! stack at ChildProcess.onCpExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:305:16)
gyp ERR! stack at emitTwo (events.js:106:13)
gyp ERR! stack at ChildProcess.emit (events.js:191:7)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:215:12)
gyp ERR! System Darwin 19.0.0
gyp ERR! command “/usr/local/bin/node” “/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js” “rebuild”
gyp ERR! cwd /Users/ryancourtney/Desktop/mflix-js/node_modules/weak-napi
gyp ERR! node -v v6.9.4
gyp ERR! node-gyp -v v3.4.0
gyp ERR! not ok
server@1.0.0 /Users/ryancourtney/Desktop/mflix-js
├── UNMET PEER DEPENDENCY babel-eslint@9.0.0
└── UNMET PEER DEPENDENCY eslint-plugin-jsx-a11y@6.2.3

npm WARN jsdom@15.2.1 requires a peer of canvas@^2.5.0 but none was installed.
npm WARN jsdom@15.2.1 requires a peer of canvas@^2.5.0 but none was installed.
npm WARN eslint-config-react-app@2.1.0 requires a peer of babel-eslint@^7.2.3 but none was installed.
npm WARN eslint-config-react-app@2.1.0 requires a peer of eslint-plugin-jsx-a11y@^5.1.1 but none was installed.
npm WARN eslint-plugin-eslint-plugin@2.1.0 requires a peer of eslint@>=5.0.0 but none was installed.
npm WARN jsdom@15.2.1 requires a peer of canvas@^2.5.0 but none was installed.
npm WARN server@1.0.0 No repository field.
npm ERR! Darwin 19.0.0
npm ERR! argv “/usr/local/bin/node” “/usr/local/bin/npm” “install”
npm ERR! node v6.9.4
npm ERR! npm v3.10.10
npm ERR! code ELIFECYCLE

npm ERR! weak-napi@1.0.3 install: node-gyp rebuild
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the weak-napi@1.0.3 install script ‘node-gyp rebuild’.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the weak-napi package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node-gyp rebuild
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs weak-napi
npm ERR! Or if that isn’t available, you can get their info via:
npm ERR! npm owner ls weak-napi
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR! /Users/ryancourtney/Desktop/mflix-js/npm-debug.log
npm ERR! code 1
ryancourtney@Ryans-MacBook-Air-8 mflix-js %

This is a known and expected error. Please try running npm start.

Kanika

This is the error I get when I run npm start, and the app doesnt start

ryancourtney@Ryans-MacBook-Air-8 mflix-js % npm start

server@1.0.0 start /Users/ryancourtney/Desktop/mflix-js
nodemon -L ./index.js

[nodemon] 1.19.4
[nodemon] to restart at any time, enter rs
[nodemon] watching dir(s): .
[nodemon] watching extensions: js,mjs,json
[nodemon] starting node ./index.js
MongoParseError: URI malformed, cannot be parsed
at parseConnectionString (/Users/ryancourtney/Desktop/mflix-js/node_modules/mongodb/lib/core/uri_parser.js:502:21)
at connect (/Users/ryancourtney/Desktop/mflix-js/node_modules/mongodb/lib/operations/connect.js:270:3)
at ConnectOperation.execute (/Users/ryancourtney/Desktop/mflix-js/node_modules/mongodb/lib/operations/connect.js:193:5)
at /Users/ryancourtney/Desktop/mflix-js/node_modules/mongodb/lib/operations/execute_operation.js:98:26
at executeOperation (/Users/ryancourtney/Desktop/mflix-js/node_modules/mongodb/lib/operations/execute_operation.js:91:10)
at MongoClient.connect (/Users/ryancourtney/Desktop/mflix-js/node_modules/mongodb/lib/mongo_client.js:226:10)
at Function.connect (/Users/ryancourtney/Desktop/mflix-js/node_modules/mongodb/lib/mongo_client.js:389:22)
at Object. (/Users/ryancourtney/Desktop/mflix-js/src/index.js:23:13)
at Module._compile (module.js:570:32)
at Module._compile (/Users/ryancourtney/Desktop/mflix-js/node_modules/pirates/lib/index.js:99:24)
[nodemon] app crashed - waiting for file changes before starting…

I am getting the same issue on my Mac. Were you able to solve it?

Not yet, was busy at work all day. Going to try and hack at it now.

Hi @Pragathi_10687, @Ryan_Courtney_8612,

Please check the following points:

  • The file is renamed to just “.env”
  • The URI should be without any double/single quotes
  • Firewall should be disabled

Please share the contents of .env file, if still not resolved.

Kanika

Are you talking about the dotenv_unix file being renamed to .env?

Yes. :slight_smile:

Kanika

I still get the app crash error:

ryancourtney@Ryans-MacBook-Air-8 ~ % cd desktop
ryancourtney@Ryans-MacBook-Air-8 desktop % cd mflix-js
ryancourtney@Ryans-MacBook-Air-8 mflix-js % mv .env dotenv_unix
ryancourtney@Ryans-MacBook-Air-8 mflix-js % mv dotenv_unix .env
ryancourtney@Ryans-MacBook-Air-8 mflix-js % npm start

server@1.0.0 start /Users/ryancourtney/Desktop/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
(node:56820) DeprecationWarning: current Server Discovery and Monitoring engine is deprecated, and will be removed in a future version. To use the new Server Discover and Monitoring engine, pass option { useUnifiedTopology: true } to MongoClient.connect.

MongoNetworkError: failed to connect to server [cluster0-shard-00-02-okwmn.mongodb.net:27017] on first connect [MongoNetworkError: connection timed out
at connectionFailureError (/Users/ryancourtney/Desktop/mflix-js/node_modules/mongodb/lib/core/connection/connect.js:362:14)
at TLSSocket. (/Users/ryancourtney/Desktop/mflix-js/node_modules/mongodb/lib/core/connection/connect.js:286:16)
at Object.onceWrapper (events.js:299:28)
at TLSSocket.emit (events.js:210:5)
at TLSSocket.Socket._onTimeout (net.js:469:8)
at listOnTimeout (internal/timers.js:531:17)
at processTimers (internal/timers.js:475:7) {
name: ‘MongoNetworkError’,
errorLabels: [Array],
[Symbol(mongoErrorContextSymbol)]: {}
}]
at Pool. (/Users/ryancourtney/Desktop/mflix-js/node_modules/mongodb/lib/core/topologies/server.js:431:11)
at Pool.emit (events.js:210:5)
at /Users/ryancourtney/Desktop/mflix-js/node_modules/mongodb/lib/core/connection/pool.js:580:14
at /Users/ryancourtney/Desktop/mflix-js/node_modules/mongodb/lib/core/connection/connect.js:39:11
at callback (/Users/ryancourtney/Desktop/mflix-js/node_modules/mongodb/lib/core/connection/connect.js:261:5)
at TLSSocket. (/Users/ryancourtney/Desktop/mflix-js/node_modules/mongodb/lib/core/connection/connect.js:286:7)
at Object.onceWrapper (events.js:299:28)
at TLSSocket.emit (events.js:210:5)
at TLSSocket.Socket._onTimeout (net.js:469:8)
at listOnTimeout (internal/timers.js:531:17)
[nodemon] app crashed - waiting for file changes before starting…

Below is whats in .env file:

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=super_secret_key_you_should_change
MFLIX_DB_URI=mongodb+srv://m220student:m220password@cluster0-okwmn.mongodb.net/test?retryWrites=true&w=majority
MFLIX_NS=sample_mflix
PORT=5000

ryancourtney@Ryans-MacBook-Air-8 mflix-js % npm test -t db-connection

server@1.0.0 test /Users/ryancourtney/Desktop/mflix-js
jest --passWithNoTests “db-connection”

Determining test suites to run…Setup Mongo Connection
FAIL test/db-connection.test.js
● Test suite failed to run

TypeError: Cannot read property 'close' of undefined

  20 | 
  21 |   async teardown() {
> 22 |     await this.global.mflixClient.close()
     |                                   ^
  23 |     await super.teardown()
  24 |   }
  25 | 

  at MongoEnvironment.teardown (test/config/mongoEnvironment.js:22:35)

Test Suites: 1 failed, 1 total
Tests: 0 total
Snapshots: 0 total
Time: 11.147s
Ran all test suites matching /db-connection/i.
Teardown Mongo Connection
Jest did not exit one second after the test run has completed.

This usually means that there are asynchronous operations that weren’t stopped in your tests. Consider running Jest with --detectOpenHandles to troubleshoot this issue.

Are you able to connect to your mongodb cluster from your system? Make sure your firewall is disabled and you are not connected to VPN.

Kanika

Yes I am able to connect to my cluster

Are you able to run application using npm start ?

Im still getting the same error for some reason

MongoDB Enterprise Cluster0-shard-0:PRIMARY> exit
bye
ryancourtney@Ryans-MacBook-Air-8 mflix-js % npm start

server@1.0.0 start /Users/ryancourtney/Desktop/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
(node:61563) DeprecationWarning: current Server Discovery and Monitoring engine is deprecated, and will be removed in a future version. To use the new Server Discover and Monitoring engine, pass option { useUnifiedTopology: true } to MongoClient.connect.
events.js:187
throw er; // Unhandled ‘error’ event
^

Error: listen EADDRINUSE: address already in use :::5000
at Server.setupListenHandle [as _listen2] (net.js:1301:14)
at listenInCluster (net.js:1349:12)
at Server.listen (net.js:1437:7)
at Function.listen (/Users/ryancourtney/Desktop/mflix-js/node_modules/express/lib/application.js:618:24)
at listen (/Users/ryancourtney/Desktop/mflix-js/src/index.js:39:9)
at tryCatch (/Users/ryancourtney/Desktop/mflix-js/node_modules/regenerator-runtime/runtime.js:45:40)
at Generator.invoke [as _invoke] (/Users/ryancourtney/Desktop/mflix-js/node_modules/regenerator-runtime/runtime.js:271:22)
at Generator.prototype. [as next] (/Users/ryancourtney/Desktop/mflix-js/node_modules/regenerator-runtime/runtime.js:97:21)
at asyncGeneratorStep (/Users/ryancourtney/Desktop/mflix-js/node_modules/@babel/runtime/helpers/asyncToGenerator.js:3:24)
at _next (/Users/ryancourtney/Desktop/mflix-js/node_modules/@babel/runtime/helpers/asyncToGenerator.js:25:9)
Emitted ‘error’ event on Server instance at:
at emitErrorNT (net.js:1328:8)
at processTicksAndRejections (internal/process/task_queues.js:80:21) {
code: ‘EADDRINUSE’,
errno: ‘EADDRINUSE’,
syscall: ‘listen’,
address: ‘::’,
port: 5000
}
[nodemon] app crashed - waiting for file changes before starting…

Hi @Ryan_Courtney_8612,

Seems like some other process is already using 5000 port. You can change the port for mflix-js application if you need.

Kanika

Ok, thank you for that answer that helped me. I still get ‘The Return from the API was incorrect’ on the mflix status page

Please check if this helps.There are couple of other threads too

Connection: The return from the api was incorrect

1 Like

Thank you that worked

1 Like