0

我已经安装了 aws-amplify 和 aws-amplify-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:\Users\PC5\Desktop\WebVezbanje\blog-kurs\node_modules\graphql'
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.
4

4 回答 4

2

您应该尝试 Amplify 版本4.3.11及更高版本,即使用graphql与 Webpack 5 一起使用的 15.8.0

于 2021-12-16T23:28:02.197 回答
2

除了弗朗西斯科更新包的建议,

您还应该卸载aws-amplify-react包以支持新的 Amplify UI 库。该遗留包的对等依赖项被锁定到旧版本的范围包将导致不需要的行为。

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

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

于 2021-12-17T00:24:06.463 回答
0

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

于 2021-12-17T18:26:43.997 回答
0

似乎 amplify 不喜欢包含在 react-scripts@5.0.0 中的 webpack 5

于 2021-12-16T11:36:29.303 回答