【问题标题】:Module not found: Error: Can't resolve 'bootstrap/dist/css/bootstrap.css' in '/codebuild/output/src489574561/src/user-management-frontend/src'找不到模块:错误:无法解析 \'/codebuild/output/src489574561/src/user-management-frontend/src\' 中的 \'bootstrap/dist/css/bootstrap.css\'
【发布时间】:2022-09-27 21:55:07
【问题描述】:

我正在尝试在 AWS Amplify 中部署 React 应用程序,但在 Build 过程中,AWS Amplify 抛出以下错误:

Module not found: Error: Can\'t resolve \'bootstrap/dist/css/bootstrap.css\' in \'/codebuild/output/src489574561/src/user-management-frontend/src\'

我想知道如何通过更改代码中的某些内容或需要配置 AWS Amplify 来解决此错误。

完整的日志跟踪在这里:

                                 # Starting phase: preBuild
                                 # Executing command: npm ci
2022-09-07T06:11:29.303Z [INFO]: > core-js@3.25.0 postinstall /codebuild/output/src489574561/src/user-management-frontend/node_modules/core-js
                                 > node -e \"try{require(\'./postinstall\')}catch(e){}\"
2022-09-07T06:11:29.350Z [INFO]: [96mThank you for using core-js ([94m https://github.com/zloirock/core-js [96m) for polyfilling JavaScript standard library![0m
                                 [96mThe project needs your help! Please consider supporting of core-js:[0m
                                 [96m>[94m https://opencollective.com/core-js [0m
                                 [96m>[94m https://patreon.com/zloirock [0m
                                 [96m>[94m bitcoin: bc1qlea7544qtsmj2rayg0lthvza9fau63ux0fstcz [0m
                                 [96mAlso, the author of core-js ([94m https://github.com/zloirock [96m) is looking for a good job -)[0m
2022-09-07T06:11:29.558Z [INFO]: > core-js-pure@3.25.0 postinstall /codebuild/output/src489574561/src/user-management-frontend/node_modules/core-js-pure
                                 > node -e \"try{require(\'./postinstall\')}catch(e){}\"
2022-09-07T06:11:29.895Z [INFO]: added 1501 packages in 21.092s
2022-09-07T06:11:29.908Z [INFO]: # Completed phase: preBuild
                                 # Starting phase: build
2022-09-07T06:11:29.908Z [INFO]: # Executing command: npm run build
2022-09-07T06:11:30.074Z [INFO]: > user-management-frontend@0.1.0 build /codebuild/output/src489574561/src/user-management-frontend
                                 > react-scripts build
2022-09-07T06:11:31.296Z [INFO]: Creating an optimized production build...
2022-09-07T06:11:31.983Z [INFO]: Failed to compile.
2022-09-07T06:11:31.983Z [INFO]: Module not found: Error: Can\'t resolve \'bootstrap/dist/css/bootstrap.css\' in \'/codebuild/output/src489574561/src/user-management-frontend/src\'
2022-09-07T06:11:31.994Z [WARNING]: npm
2022-09-07T06:11:31.994Z [WARNING]: ERR! code ELIFECYCLE
                                    npm ERR! errno 1
2022-09-07T06:11:31.996Z [WARNING]: npm
2022-09-07T06:11:31.996Z [WARNING]: ERR! user-management-frontend@0.1.0 build: `react-scripts build`
                                    npm ERR! Exit status 1
                                    npm ERR!
                                    npm ERR! Failed at the user-management-frontend@0.1.0 build script.
                                    npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2022-09-07T06:11:32.000Z [WARNING]: 
2022-09-07T06:11:32.000Z [WARNING]: npm ERR! A complete log of this run can be found in:
                                    npm ERR!     /root/.npm/_logs/2022-09-07T06_11_31_997Z-debug.log
2022-09-07T06:11:32.000Z [HELP]: Outputting the npm debug log
                                 [object Promise]
2022-09-07T06:11:32.003Z [ERROR]: !!! Build failed
2022-09-07T06:11:32.003Z [ERROR]: !!! Non-Zero Exit Code detected
2022-09-07T06:11:32.003Z [INFO]: # Starting environment caching...
2022-09-07T06:11:32.004Z [INFO]: # Environment caching completed
Terminating logging...

    标签: reactjs amazon-web-services aws-amplify


    【解决方案1】:

    尝试安装引导程序,这就是我解决它的方法。

    npm install bootstrap --save
    

    【讨论】:

      猜你喜欢
      • 2019-08-05
      • 1970-01-01
      • 2019-01-27
      • 2019-11-22
      • 2022-07-10
      • 1970-01-01
      • 2021-03-19
      • 2023-01-05
      • 2019-11-15
      相关资源
      最近更新 更多