Skip to content
This repository was archived by the owner on Jan 26, 2019. It is now read-only.

Error: Cannot find module '/home/user/test/node_modules/jest-cli' #154

Open
comerc opened this issue Aug 31, 2017 · 13 comments
Open

Error: Cannot find module '/home/user/test/node_modules/jest-cli' #154

comerc opened this issue Aug 31, 2017 · 13 comments

Comments

@comerc
Copy link
Contributor

comerc commented Aug 31, 2017

Environment

  1. npm ls react-scripts-ts (if you haven’t ejected): └── (empty)

  2. node -v: v8.4.0

  3. npm -v: 5.3.0

  4. yarn --version (if you use Yarn): 0.27.5

  5. Operating system: Ubuntu 14.04

Steps to Reproduce

  1. create-react-app test --scripts-version=react-scripts-ts
  2. cd test && npm install
  3. npm run eject
  4. npm run test
> node scripts/test.js --env=jsdom

module.js:491
    throw err;
    ^

Error: Cannot find module '/home/user/test/node_modules/jest-cli'
    at Function.Module._resolveFilename (module.js:489:15)
    at Function.Module._load (module.js:439:25)
    at Module.require (module.js:517:17)
    at require (internal/module.js:11:18)
    at getJest (/home/user/test/node_modules/jest/node_modules/jest-cli/build/cli/getJest.js:22:12)
    at Object.run (/home/user/test/node_modules/jest/node_modules/jest-cli/build/cli/index.js:39:48)
    at Object.<anonymous> (/home/user/test/scripts/test.js:27:6)
    at Module._compile (module.js:573:30)
    at Object.Module._extensions..js (module.js:584:10)
    at Module.load (module.js:507:32)
@wmonk
Copy link
Owner

wmonk commented Sep 7, 2017

Hmm, not sure why this happens. Is jest listed in your package.json?

@dbenchi
Copy link

dbenchi commented Sep 11, 2017

I have the same error

@jiverson
Copy link

Fyi I think it is this issue jestjs/jest#4419

@ryanbrainard
Copy link

ryanbrainard commented Nov 16, 2017

Deleting my node_modules and reinstalling them fixed it for me. I was playing around with yarn and npm together and I think some wires got crossed.

@amackintosh
Copy link

amackintosh commented Nov 22, 2017

Confirmed, wiping node_modules and yarn.lock and doing yarn install fixed mine.

It works again following that as yarn test.

I have a feeling my reason was the same as ryanbrainard's. I also mixed a bit of npm and yarn along the way.

@johnkingzy
Copy link

@ryanbrainard and @amackintosh Thanks for this. I also came across the same issue, I think the best way to stay away from this issue is to stick with one package manager.

rm -rf node_modules/ && yarn install solved mine

@TallOrderDev
Copy link

Just ran into this too... blowing away node modules and running yarn install again fixed this. Not sure why this happened!

@lsemerini
Copy link

I had this issue today, and as @ryanbrainard mentioned, it was because I installed something with npm and before I did with yarn. So mixing both together caused this.

And yes, wiping out node_modules fixed it.

@atopus
Copy link

atopus commented Jun 9, 2018

Same here : fixed by removing node_modules and reinstalling with yarn install.

Thanks :)

@sanchit94
Copy link

I bumped into this even though I was just using npm, so it is probably not just about mixing package manages. But thanks guys for the fix it worked like magic!

@khanhhd
Copy link

khanhhd commented Aug 1, 2018

Thanks @ryanbrainard

@Reebby
Copy link

Reebby commented Sep 20, 2018

awesome this worked like a charm
rm -rf node_modules/ && yarn install
thanks @andela-ksolomon

@nour-s
Copy link

nour-s commented Nov 22, 2018

Removing node_modules solved mine too! Very weird!

# for free to subscribe to this conversation on GitHub. Already have an account? #.
Projects
None yet
Development

No branches or pull requests