简体   繁体   中英

Error while installing React - "Cannot find module 'block-stream'

  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

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

If you do run npm install create-react-app && create-react-app React_js , make sure you run npm list -g create-react-app again

Try this:

1.Go to your _npx directory and remove the c67e74de0542c87c file ( in your case: )

cd C:\\Users\\DELL\\AppData\\Local\\npm-cache\\_npx\\
rmdir c67e74de0542c87c

2.Run:

npx create-react-app

3.Enter y for prompt:

Need to install the following packages:
  create-react-app@5.0.1
Ok to proceed? (y) y

create-react-app should work now.

I ran "npm i block-stream" on the terminal.

Then in my project folder I ran "npx create-react-app" and that worked for me.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM