AWS 放大反应 - 无法启动项目



我安装了aws-amplifier和aws-amplier-react包,这是我的index.js:

import React from 'react';
import ReactDOM from 'react-dom';
import './index.css';
import App from './App';
import Amplify from 'aws-amplify';
import aws_exports from './aws-exports';
Amplify.configure(aws_exports);
ReactDOM.render(
<React.StrictMode>
<App />
</React.StrictMode>,
document.getElementById('root')
);

当我尝试启动应用程序时,我得到了这个错误:

ERROR in ./node_modules/graphql/index.mjs 64:0-98:42
Module not found: Error: Can't resolve './utilities' in 'C:UsersPC5DesktopWebVezbanjeblog-kursnode_modulesgraphql'
Did you mean 'index.mjs'?
BREAKING CHANGE: The request './utilities' failed to resolve only because it was resolved as fully specified
(probably because the origin is strict EcmaScript Module, e. g. a module with javascript mimetype, a '*.mjs' file, or a '*.js' file where the package.json contains '"type": "module"').
The extension in the request is mandatory for it to be fully specified.
Add the extension to the request.

除了Francisco建议更新包外,

您还应该卸载aws-amplify-react软件包,以使用新的Amplify UI库。将旧包的对等依赖项锁定到作用域包的旧版本将导致不必要的行为。

您可以通过运行npm i @aws-amplify/ui-react来安装新的ui组件

以下是新的Amplify UI文档的链接以供参考:https://ui.docs.amplify.aws/

您应该尝试Amplify版本4.3.11及更高版本,即使用与Webpack 5 配合使用的graphql15.8.0

aws-amplify-react已被弃用,因此如果您有此问题,只需卸载aws-amplady-react并安装@aws amplify-/ui-react即可。它对我有效

似乎amplify不喜欢包含在react-scripts@5.0.0