Home > front end >  Error while installing React - "Cannot find module 'block-stream'
Error while installing React - "Cannot find module 'block-stream'

Time:05-24

  1. This is the line executed:

    PS E:\React_js> npx create-react-app React_js
    node:internal/modules/cjs/loader:942
    throw err;
    ^
    
  2. The error tells cannot find module:

    Error: Cannot find module 'block-stream'
    Require stack:
     at Module._resolveFilename (node:internal/modules/cjs/loader:939:15)
     at Module._load (node:internal/modules/cjs/loader:780:27)
     at Module.require (node:internal/modules/cjs/loader:1005:19)
     at require (node:internal/modules/cjs/helpers:102:18)
     at Object.<anonymous> (C:\Users\DELL\AppData\Local\npm-cache\_npx\c67e74de0542c87c\node_modules\tar-pack\node_modules\tar\lib\entry-writer.js:7:19)
     at Module._compile (node:internal/modules/cjs/loader:1105:14)
     at Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
     at Module.load (node:internal/modules/cjs/loader:981:32)
     at Module._load (node:internal/modules/cjs/loader:827:12)
     at Module.require (node:internal/modules/cjs/loader:1005:19) {
    
     code: 'MODULE_NOT_FOUND', requireStack: [
       'C:\\Users\\DELL\\AppData\\Local\\npm-cache\\_npx\\c67e74de0542c87c\\node_modules\\tar-pack\\node_modules\\tar\\lib\\entry-writer.js',
       'C:\\Users\\DELL\\AppData\\Local\\npm-cache\\_npx\\c67e74de0542c87c\\node_modules\\tar-pack\\node_modules\\tar\\lib\\pack.js',
       'C:\\Users\\DELL\\AppData\\Local\\npm-cache\\_npx\\c67e74de0542c87c\\node_modules\\tar-pack\\node_modules\\tar\\tar.js',
       'C:\\Users\\DELL\\AppData\\Local\\npm-cache\\_npx\\c67e74de0542c87c\\node_modules\\tar-pack\\index.js',
       'C:\\Users\\DELL\\AppData\\Local\\npm-cache\\_npx\\c67e74de0542c87c\\node_modules\\create-react-app\\createReactApp.js',
       'C:\\Users\\DELL\\AppData\\Local\\npm-cache\\_npx\\c67e74de0542c87c\\node_modules\\create-react-app\\index.js'
     ]
    
  3. I have tried executing it on both VS and cmd
    Nodejs version v18.0.0

CodePudding user response:

This can be hard to debug as there could be many issues. I suggest going back to step one following the documentation on create-react-app

As the docs state you need to delete create-react-app if you have installed it globally in order to ensure you have the latest version. You can check a globally installed package like so:

npm list -g create-react-app

If it is installed globally, run the uninstall command to remove it:

npm uninstall -g create-react-app

From here you can repeat the steps in the docs using npx.

Alternatively, instead of using npx you can try with just npm:

npm install create-react-app && create-react-app React_js

If this doesn't work, you can always try building using yarn

  • Related