create-react-app-typescript icon indicating copy to clipboard operation
create-react-app-typescript copied to clipboard

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

Open comerc opened this issue 7 years ago • 13 comments

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)

comerc avatar Aug 31 '17 12:08 comerc

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

wmonk avatar Sep 07 '17 08:09 wmonk

I have the same error

dbenchi avatar Sep 11 '17 07:09 dbenchi

Fyi I think it is this issue https://github.com/facebook/jest/issues/4419

jiverson avatar Sep 14 '17 16:09 jiverson

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.

ryanbrainard avatar Nov 16 '17 07:11 ryanbrainard

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.

amackintosh avatar Nov 22 '17 01:11 amackintosh

@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

johnkingzy avatar Jan 30 '18 22:01 johnkingzy

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

TallOrderDev avatar Apr 20 '18 18:04 TallOrderDev

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.

lsemerini avatar Jun 07 '18 15:06 lsemerini

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

Thanks :)

atopus avatar Jun 09 '18 13:06 atopus

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!

sanchit94 avatar Jul 30 '18 11:07 sanchit94

Thanks @ryanbrainard

khanhhd avatar Aug 01 '18 08:08 khanhhd

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

Reebby avatar Sep 20 '18 12:09 Reebby

Removing node_modules solved mine too! Very weird!

nour-s avatar Nov 22 '18 12:11 nour-s