Vscode-jest: ENOENT: no such file or directory, access '<project dir>/node_modules/jest/bin/package.json'

Created on 5 Sep 2019  路  2Comments  路  Source: jest-community/vscode-jest

Environment

  1. node -v: v8.10.0
  2. npm -v: 6.8.0
  3. npm ls jest or npm ls react-scripts (if you haven鈥檛 ejected): [email protected]
  4. Operating system: OSX 10.14

Prerequisite

  • are you able to run jest test from command line? yes
  • how do you run your tests from command line? npm run test [test module] -- [--watch]

Steps to Reproduce

Working on Javascript project. I cannot reproduce the issue outside of my machine. But for me, I can reproduce by clicking the "Debug" code lens piece above a unit test. Doesn't matter what test module, as far as I can tell.

This functionality worked for months after switching to vscode earlier this year. But it seems after some update somewhere, something has gone askance.

Relevant Debug Info

Here is a screenshot of the error:

image

Here is a paste of the error message:

Exception has occurred: Error
Error: ENOENT: no such file or directory, access '/Users/mdeboard/truecar/consumer-frontend/node_modules/jest/bin/package.json'
    at Object.fs.accessSync (fs.js:322:11)
    at Function.module.exports.sync.fp [as sync] (/Users/mdeboard/truecar/consumer-frontend/node_modules/pkg-dir/node_modules/path-exists/index.js:12:6)
    at Function.module.exports.sync (/Users/mdeboard/truecar/consumer-frontend/node_modules/pkg-dir/node_modules/locate-path/index.js:20:18)
    at Function.module.exports.sync (/Users/mdeboard/truecar/consumer-frontend/node_modules/pkg-dir/node_modules/find-up/index.js:34:27)
    at Function.module.exports.sync.cwd [as sync] (/Users/mdeboard/truecar/consumer-frontend/node_modules/pkg-dir/index.js:8:20)
    at module.exports.filename (/Users/mdeboard/truecar/consumer-frontend/node_modules/import-local/index.js:7:27)
    at Object.<anonymous> (/Users/mdeboard/truecar/consumer-frontend/node_modules/jest/bin/jest.js:11:6)
    at Module._compile (module.js:646:14)
    at Object.Module._extensions..js (module.js:660:10)
    at Module.load (module.js:561:32)

Expected Behavior

Test should run. Historically it has been great.

Actual Behavior

An exception is thrown that it cannot find node_modules/jest/bin/package.json

Most helpful comment

Ok I just figured this out. As per usual, PEBCAK.

I had checked, "All Exceptions" in the Jest test-runner UI. Unchecking that resolved it.

image

All 2 comments

Ok I just figured this out. As per usual, PEBCAK.

I had checked, "All Exceptions" in the Jest test-runner UI. Unchecking that resolved it.

image

I was trying to work out what was missing in package.json. Never would have thought to uncheck All Exceptions. Thanks!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

therazor picture therazor  路  36Comments

erikns picture erikns  路  16Comments

dandv picture dandv  路  17Comments

Glutnix picture Glutnix  路  37Comments

connectdotz picture connectdotz  路  24Comments