Cannot find module '<project path>/src/package.json' after run (by mistake) create package.json

Hello, good day, I've an annoying problem, I wanted to jump to the package.json file but by mistake I click over "package.json file File|New" this actions created a new package.json file under my src directory...ok I removed this and hope everything works as expected...but nope...after remove this new created file when I try to run my test I get this error


Error: Cannot find module '/<my folder>/src/package.json'

If I run the test using the command line, this works as expected, by the way, we're talking about a create-react-app project

In desperation I decided to delete the .idea file thinking that it was better to regenerate it because a strange configuration could have been added there, this didn't work, even worse, now I don't have the button to run test inline in my test file (you know, the handly button at the right of the line number in the editor)

It is a bit impressive as a small error can cause a loss of time of this caliber, I hope you can tell me how I can fix my editor to correct this problem :tired_face: 


thank you so much, have a great day



Comment actions Permalink

after remove the .idea folder for second time and restart the IDE seems work fine again :D...seems very dangerous use that create package.json file and this does things behind the scene that users probably doesn't expect...

Comment actions Permalink

Just creating a package.json doesn't normally do anything of this kind; you must have changed the run configuration you were using to run your tests (by choosing a different package.json or working directory there)

Comment actions Permalink

thank you Elena Pogorelova, my unit test are working as expected but my e2e test doesn't run through the IDE, I can run manually them through the cli but the issue with the package.json path still fails


Error: Cannot find module '..../src/e2e/package.json'

I've this folder structure










module.exports = {
preset: 'jest-playwright-preset',
testMatch: ["**/specs/*.e2e.ts"],
/*transform: {
"\\.js$": "react-scripts/config/jest/babelTransform"
transform: {
'^.+\\.ts?$': 'ts-jest',


module.exports = {
browsers: ['chromium', 'firefox', 'webkit'],
serverOptions: {
command: `npm start`,
port: 5000,
launchTimeout: 10000,
debug: true,

verbose: true
launchOptions: {
headless: false

when I clicked the run button the IDE automatically generate the configuration for run the test

seems to be correct:


configuration file is set to jest.config.js

jest package is /node_modules/react-scripts

working directory is src/e2e

test file is index.e2e.ts


I don't know why this e2e test (unit test are working fine) points to some weird package.json inside the /src folder...


hope you can know which is the problem here...thank you so much!

Comment actions Permalink

Hmm... Likely because of

`npm start`

command in your jest-playwright.config.js - it requires a package.json with the corresponding script to run. Not sure how it can work for you outside of the IDE...


Please sign in to leave a comment.