Sh: jest: command not found

Hi, I’m able to run npm start succesfully but I’m having some trouble running npm test -t db-connection

When I run npm test -t db-connection I get this

> server@1.0.0 test /Users/Me/MongoDBUni/mflix-js
> jest --passWithNoTests "db-connection"

sh: jest: command not found
npm ERR! Test failed.  See above for more details.

When I run npm install and npm install jest I get the following error:

> weak-napi@1.0.3 install /Users/Me/MongoDBUni/mflix-js/node_modules/weak-napi
> node-gyp rebuild

  CXX(target) Release/obj.target/node-api/../node-addon-api/src/node_api.o
  CXX(target) Release/obj.target/node-api/../node-addon-api/src/node_internals.o
  LIBTOOL-STATIC Release/node-api.a
  CXX(target) Release/obj.target/weakref/src/weakref.o
In file included from ../src/weakref.cc:1:
/Users/Me/MongoDBUni/mflix-js/node_modules/node-addon-api/napi.h:987:24: error: unknown type name 'napi_async_context'
                       napi_async_context context = nullptr) const;
                       ^
/Users/Me/MongoDBUni/mflix-js/node_modules/node-addon-api/napi.h:990:24: error: unknown type name 'napi_async_context'
                       napi_async_context context = nullptr) const;
                       ^
/Users/Me/MongoDBUni/mflix-js/node_modules/node-addon-api/napi.h:994:24: error: unknown type name 'napi_async_context'
                       napi_async_context context = nullptr) const;
                       ^
/Users/Me/MongoDBUni/mflix-js/node_modules/node-addon-api/napi.h:987:43: error: cannot initialize a parameter of type
      'int' with an rvalue of type 'nullptr_t'
                       napi_async_context context = nullptr) const;
                                          ^         ~~~~~~~
/Users/Me/MongoDBUni/mflix-js/node_modules/node-addon-api/napi.h:987:43: note: passing argument to parameter 'context'
      here
/Users/Me/MongoDBUni/mflix-js/node_modules/node-addon-api/napi.h:990:43: error: cannot initialize a parameter of type
      'int' with an rvalue of type 'nullptr_t'
                       napi_async_context context = nullptr) const;
                                          ^         ~~~~~~~
/Users/Me/MongoDBUni/mflix-js/node_modules/node-addon-api/napi.h:990:43: note: passing argument to parameter 'context'
      here
/Users/Me/MongoDBUni/mflix-js/node_modules/node-addon-api/napi.h:994:43: error: cannot initialize a parameter of type
      'int' with an rvalue of type 'nullptr_t'
                       napi_async_context context = nullptr) const;
                                          ^         ~~~~~~~
/Users/Me/MongoDBUni/mflix-js/node_modules/node-addon-api/napi.h:994:43: note: passing argument to parameter 'context'
      here
/Users/Me/MongoDBUni/mflix-js/node_modules/node-addon-api/napi.h:1016:7: error: unknown type name 'napi_deferred'
      napi_deferred _deferred;
      ^
/Users/Me/MongoDBUni/mflix-js/node_modules/node-addon-api/napi.h:1168:30: error: unknown type name 'napi_async_context'
                             napi_async_context context = nullptr) const;
                             ^
/Users/Me/MongoDBUni/mflix-js/node_modules/node-addon-api/napi.h:1171:30: error: unknown type name 'napi_async_context'
                             napi_async_context context = nullptr) const;
                             ^
/Users/Me/MongoDBUni/mflix-js/node_modules/node-addon-api/napi.h:1175:30: error: unknown type name 'napi_async_context'
                             napi_async_context context = nullptr) const;
                             ^
/Users/Me/MongoDBUni/mflix-js/node_modules/node-addon-api/napi.h:1168:49: error: cannot initialize a parameter of type
      'int' with an rvalue of type 'nullptr_t'
                             napi_async_context context = nullptr) const;
                                                ^         ~~~~~~~
/Users/Me/MongoDBUni/mflix-js/node_modules/node-addon-api/napi.h:1168:49: note: passing argument to parameter 'context'
      here
/Users/Me/MongoDBUni/mflix-js/node_modules/node-addon-api/napi.h:1171:49: error: cannot initialize a parameter of type
      'int' with an rvalue of type 'nullptr_t'
                             napi_async_context context = nullptr) const;
                                                ^         ~~~~~~~
/Users/Me/MongoDBUni/mflix-js/node_modules/node-addon-api/napi.h:1171:49: note: passing argument to parameter 'context'
      here
/Users/Me/MongoDBUni/mflix-js/node_modules/node-addon-api/napi.h:1175:49: error: cannot initialize a parameter of type
      'int' with an rvalue of type 'nullptr_t'
                             napi_async_context context = nullptr) const;
                                                ^         ~~~~~~~
/Users/Me/MongoDBUni/mflix-js/node_modules/node-addon-api/napi.h:1175:49: note: passing argument to parameter 'context'
      here
/Users/Me/MongoDBUni/mflix-js/node_modules/node-addon-api/napi.h:1759:14: error: unknown type name 'napi_async_context'
    operator napi_async_context() const;
             ^
/Users/Me/MongoDBUni/mflix-js/node_modules/node-addon-api/napi.h:1763:5: error: unknown type name 'napi_async_context'
    napi_async_context _context;
    ^
/Users/Me/MongoDBUni/mflix-js/node_modules/node-addon-api/napi.h:2045:20: error: unknown type name 'napi_node_version'
      static const napi_node_version* GetNodeVersion(Env env);
                   ^
In file included from ../src/weakref.cc:1:
In file included from /Users/Me/MongoDBUni/mflix-js/node_modules/node-addon-api/napi.h:2051:
/Users/Me/MongoDBUni/mflix-js/node_modules/node-addon-api/napi-inl.h:437:24: error: use of undeclared identifier
      'napi_is_promise'
  napi_status status = napi_is_promise(_env, _value, &result);
                       ^
/Users/Me/MongoDBUni/mflix-js/node_modules/node-addon-api/napi-inl.h:535:24: error: use of undeclared identifier
      'napi_create_double'
  napi_status status = napi_create_double(env, val, &value);
                       ^
/Users/Me/MongoDBUni/mflix-js/node_modules/node-addon-api/napi-inl.h:1669:43: error: use of undeclared identifier
      'NAPI_AUTO_LENGTH'
      napi_create_function(env, utf8name, NAPI_AUTO_LENGTH, cb, data, result);
                                          ^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
make: *** [Release/obj.target/weakref/src/weakref.o] Error 1
gyp ERR! build error 
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:258:23)
gyp ERR! stack     at emitTwo (events.js:125:13)
gyp ERR! stack     at ChildProcess.emit (events.js:213:7)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:200:12)
gyp ERR! System Darwin 16.7.0
gyp ERR! command "/usr/local/Cellar/node/8.3.0_1/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /Users/Me/MongoDBUni/mflix-js/node_modules/weak-napi
gyp ERR! node -v v8.3.0
gyp ERR! node-gyp -v v3.6.2
gyp ERR! not ok 
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 server@1.0.0 No repository field.

npm ERR! code ELIFECYCLE
npm ERR! errno 1
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.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/Me/.npm/_logs/2019-11-14T13_21_17_020Z-debug.log

I’m on node v8.3.0 and npm v5.3.0 if that helps!

Hi @Zee_96010,

Make sure to run npm install before running npm test commands.

Kanika

Hi, I did. You can see my error logs in my question details.

Thanks!

Hi, I believe I did post this in M220 for Javascript.

If that’s not the case let me know how I can fix it. Thanks!

Sorry, it was my mistake!

Hi @Zee_96010,

It was for M220J but I changed it to M220JS :slight_smile:

And Sorry, I missed that part. Can you try the following:

  1. Delete the node_modules/jest directory
  2. Re-ran npm install

Don’t worry about this error. This is expected and it will not interfere with the application.

Kanika