0
votes

When using npx create-react-app to create a new react project, the process stops with error : internal/modules/cjs/loader.js:311.

internal/modules/cjs/loader.js:311 throw err; ^ Error: Cannot find module 'C:\Users\shonm\Desktop\Web Development\WebSites\test1\node_modules\fs-extra\lib\index.js'. Please verify that the package.json has a valid "main" entry

 PS C:\Users\shonm\Desktop\Web Development\WebSites> npx create-react-app test1

Installing packages. This might take a couple of minutes.
Installing react, react-dom, and react-scripts with cra-template...

yarn add v1.22.4
[1/4] Resolving packages...
[2/4] Fetching packages...
info [email protected]: The platform "win32" is incompatible with this module.
info "[email protected]" is an optional dependency and failed compatibility check. Excluding it from installation.
info [email protected]: The platform "win32" is incompatible with this module.
info "[email protected]" is an optional dependency and failed compatibility check. Excluding it from installation.
[3/4] Linking dependencies...
.......
Done in 30.17s.
**internal/modules/cjs/loader.js:311
      throw err;
      ^
Error: Cannot find module 'C:\Users\shonm\Desktop\Web Development\WebSites\test1\node_modules\fs-extra\lib\index.js'. Please verify that the package.json has a valid "main" 
entry**
    at tryPackage (internal/modules/cjs/loader.js:303:19)
  
  requestPath: 'fs-extra'
}

Aborting installation.
  node  has failed.

Deleting generated file... node_modules
1

1 Answers

0
votes

This happens when there is both npm and yarn installed globally. The create-react-app was using yarn to build. To fix this, use npx create-react-app projectname --use-npm, or remove yarn from global package.

Also verify, if the node installation is proper with node -v && npm -v