当我尝试使用 npm 和yarn 创建一个 React 项目时,它显示以下错误:
我尝试重新安装节点并确保它是最新的,以及通过运行 npm install -g create-react-app@latest 来创建-react-app。我还删除了 npm 和 npm-cache 文件夹以及环境变量,但对我来说没有任何作用,并且我不断收到相同的错误。
internal/modules/cjs/loader.js:638
throw err;
^
Error: Cannot find module 'react-scripts/scripts/init.js'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
at Function.Module._load (internal/modules/cjs/loader.js:562:25)
at Module.require (internal/modules/cjs/loader.js:692:17)
at require (internal/modules/cjs/helpers.js:25:18)
at [eval]:2:20
at Script.runInThisContext (vm.js:122:20)
at Object.runInThisContext (vm.js:329:38)
at Object.<anonymous> ([eval]-wrapper:6:22)
at Module._compile (internal/modules/cjs/loader.js:778:30)
at evalScript (internal/bootstrap/node.js:589:27)
Aborting installation.
node has failed.
Deleting generated file... node_modules
Deleting generated file... package.json
Deleting generated file... yarn.lock
Deleting test/ from C:\Users\Esper\projects
Done.
我认为问题是由于操作系统问题而将我的 Windows 10 恢复到以前的状态,因为在恢复之前,当我运行 create-react-app 时它工作正常。
创建反应应用程序--版本
3.1.1
节点-v
v10.16.3
npm-v
6.9.0
所以
Windows 10 教育版
安装 package.jsonnpm init
(按 Enter 直到安装)
之后安装react-scriptsnpm i react-scripts
,
然后你可以安装reactnpx create-react-app your-app
.
将目录更改为“你的应用程序”
再次运行npm i react-scripts
它应该有效。
希望我没有错过任何一步,如果有效请告诉我:)
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)