描述bug
在my-app文件夹中使用npx create-react-app my-app
对React进行了干净的安装后,npm start
命令无法初始化开发服务器并产生了模块未找到错误。
'D\my-app\node_modules\.bin\' is not recognized as an internal or external command,
operable program or batch file.
node:internal/modules/cjs/loader:936
throw err;
^
Error: Cannot find module 'D:\Neil\Web Projects\Frontend\react-scripts\bin\react-scripts.js'
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
at Function.Module._load (node:internal/modules/cjs/loader:778:27)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
at node:internal/main/run_main_module:17:47 {
code: 'MODULE_NOT_FOUND',
requireStack: []
}
环境
Environment Info:
current version of create-react-app: 5.0.1
running from C:\Users\neilb\AppData\Local\npm-cache\_npx\c67e74de0542c87c\node_modules\create-react-app
System:
OS: Windows 10 10.0.22000
CPU: (8) x64 AMD Ryzen 5 3550H with Radeon Vega Mobile Gfx
Binaries:
Node: 16.13.2 - C:\Program Files\nodejs\node.EXE
Yarn: Not Found
npm: 8.13.2 - C:\Program Files\nodejs\npm.CMD
Browsers:
Chrome: Not Found
Edge: Spartan (44.22000.120.0), Chromium (103.0.1264.49)
Internet Explorer: 11.0.22000.120
npmPackages:
react: ^18.2.0 => 18.2.0
react-dom: ^18.2.0 => 18.2.0
react-scripts: 5.0.1 => 5.0.1
npmGlobalPackages:
create-react-app: Not Found
似乎无法解决该问题,请帮忙!
3条答案
按热度按时间vjrehmav1#
cd into the folder you want to create my-app
then run this in your terminal
npx create-react-app my-app
cd my-app
npm run start
this should work
kxkpmulp2#
请使用vite并运行:
npm init vite
然后,选择react模板。
w8biq8rn3#
请打开 package.json 文件,在 dependencies 下面将 start 重写为 "start" : "node node_modules/react-scripts/bin/react-scripts start"。然后在终端运行命令: npm run start