【问题标题】:./src/index.js Module not found: Can't resolve 'aws-amplify' React./src/index.js 未找到模块:无法解析“aws-amplify”反应
【发布时间】:2021-06-20 11:31:14
【问题描述】:

我正在尝试学习 AWS 并做出反应。当我使用“NPM start”在本地机器上运行我的 react 应用程序时,我不断收到以下错误。

./src/index.js 未找到模块:无法解析“C:\Users\pull-transactions\src”中的“aws-amplify”

在 Resolver.resolveModule (node_modules/jest-runtime/node_modules/jest-resolve/build/index.js:306:11) 在对象。 (src/components/PlaidLink.js:3:1)

index.js 配置:

import React from 'react';
import ReactDOM from 'react-dom';
import './index.css';
import App from './App';
import reportWebVitals from './reportWebVitals';
import Amplify from 'aws-amplify';
import config from './aws-exports';
Amplify.configure(config);

ReactDOM.render(
  <React.StrictMode>
    <App />
  </React.StrictMode>,
  document.getElementById('root')
);

我花了几个小时搜索谷歌,但找不到任何关于此的内容。我有另一个运行良好的应用程序,两者的文件结构看起来相同。任何帮助表示赞赏。如果您需要更多信息,请告诉我。

【问题讨论】:

  • 你真的安装了这个包吗?

标签: reactjs aws-amplify


【解决方案1】:

您必须先安装该软件包,然后才能使用它。

$ npm install # installs packages listed in your package.json file
$ npm install --save aws-amplify # installs the aws-amplify package and saves it to your package.json file

【讨论】:

  • 这是假设您使用npm - 如果您使用的是yarn,请执行$ yarn install。另外,希望很清楚该命令应该从存在package.json 的根项目目录运行
猜你喜欢
  • 2021-08-18
  • 2021-03-19
  • 2018-11-19
  • 2022-06-16
  • 2020-03-08
  • 2017-12-28
  • 2020-01-07
  • 2022-10-21
  • 2020-09-21
相关资源
最近更新 更多