如何解决React 无法启动项目 - 'craco' 未被识别为内部或外部命令
谁能告诉我为什么我不能在开发服务器上启动我的网站项目?
我在 Windows 10 上克隆了一个文件,这曾经在我的 Mac OS 上运行良好......在它死之前:'(随意尝试这个项目:https://github.com/EMDevelop/j2c
当我运行 npm start
时,我收到以下消息
> just2connect@0.1.0 start C:\Users\Ed\Desktop\Coding\React\j2c
> craco start
'craco' is not recognized as an internal or external command,operable program or batch file.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! just2connect@0.1.0 start: `craco start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the just2connect@0.1.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Ed\AppData\Roaming\npm-cache\_logs\2021-03-26T16_11_19_513Z-debug.log
这很奇怪,因为我有 "craco": "0.0.3"
作为依赖项,而 "start": "craco start"
作为我的 package.json
中的脚本。
我在项目中还有 craco.config
文件,@craco
文件夹中有 node_modules
文件夹。
当我再次尝试安装 craco (npm i @craco/craco
) 并运行 npm start
时,出现以下错误,要求我安装依赖项:
C:\Users\Ed\Desktop\Coding\React\j2c>npm i @craco/craco
npm WARN bootstrap@4.6.0 requires a peer of popper.js@^1.16.1 but none is installed. You must install peer dependencies yourself.
npm WARN radium@0.25.2 requires a peer of react@^15.3.0 || ^16.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN react-coverflow@0.2.20 requires a peer of react@^16.5.2 but none is installed. You must install peer dependencies yourself.
npm WARN react-native-elements@3.2.0 requires a peer of react-native-vector-icons@>7.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN react-native-elements@3.2.0 requires a peer of react-native-safe-area-context@^3.1.9 but none is installed. You must install peer dependencies yourself.
npm WARN react-native-ratings@7.3.0 requires a peer of react-native@* but none is installed. You must install peer dependencies yourself.
npm WARN react-native-size-matters@0.3.1 requires a peer of react-native@* but none is installed. You must install peer dependencies yourself.
npm WARN react-only-when@1.0.2 requires a peer of react@^15.0.0 || ^16.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN react-only-when@1.0.2 requires a peer of react-dom@^15.0.0 || ^16.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN react-particles-js@3.4.1 requires a peer of react@^16.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN react-swipeable@5.5.1 requires a peer of react@^16.0.0-0 but none is installed. You must install peer dependencies yourself.
npm WARN react-testimonial@1.0.0 requires a peer of react@^16.11.0 but none is installed. You must install peer dependencies yourself.
npm WARN tsutils@3.20.0 requires a peer of typescript@>=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta but none is installed. You must install peer dependencies yourself.
npm ERR! code EEXIST
npm ERR! path C:\Users\Ed\Desktop\Coding\React\j2c\node_modules\.bin\craco
npm ERR! Refusing to delete C:\Users\Ed\Desktop\Coding\React\j2c\node_modules\.bin\craco: is outside C:\Users\Ed\Desktop\Coding\React\j2c\node_modules\@craco\craco and not a link
npm ERR! File exists: C:\Users\Ed\Desktop\Coding\React\j2c\node_modules\.bin\craco
npm ERR! Remove the existing file and try again,or run npm
npm ERR! with --force to overwrite files recklessly.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Ed\AppData\Roaming\npm-cache\_logs\2021-03-26T16_29_51_457Z-debug.log
这也很奇怪,因为我在 node_modules
文件夹(和 package.json
)中拥有大部分这些依赖项:
我担心只是不顾后果地强迫 craco 替换旧版本,然后我是否必须对它给我警告的每个依赖项都这样做?其中大部分依赖项已经存在。
然后,当我再次尝试运行 npm start
时,它给了我错误,就好像我从未再次安装过 craco:
C:\Users\Ed\Desktop\Coding\React\j2c>npm start
> just2connect@0.1.0 start C:\Users\Ed\Desktop\Coding\React\j2c
> craco start
'craco' is not recognized as an internal or external command,operable program or batch file.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! just2connect@0.1.0 start: `craco start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the just2connect@0.1.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Ed\AppData\Roaming\npm-cache\_logs\2021-03-26T16_30_25_218Z-debug.log
任何帮助将不胜感激!!拔头发,我是 Windows 新手。
解决方法
这对我有用
npm install @craco/craco --save
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。