React构建在本地运行,但在Amplify上失败

如何解决React构建在本地运行,但在Amplify上失败

有什么主意吗?如何调试而不重新开始?在API,GraphQL和CI上投入了大量时间。

这是一个普通的create-react-app,在App.js中做了一些小的更改。在节点12.18.3和npm 6.14.8本地启动和构建。使用npm@6.9.0和node@v10.16.0的Amplify构建失败。

我正在尝试避免自定义Docker映像升级节点和npm。

已编辑以添加index.js-构建日志来自尝试将.js附加到./App导入

index.js

import ReactDOM from 'react-dom';
import './index.css';
import App from './App';
import * as serviceWorker from './serviceWorker';

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

// If you want your app to work offline and load faster,you can change
// unregister() to register() below. Note this comes with some pitfalls.
// Learn more about service workers: link omitted
serviceWorker.unregister();

App.js

import React from 'react';
import logo from './images/logo.png';
import './App.css';

function App() {
  return (
    <div className="App">
      <header className="App-header">
        <img src={logo} className="App-logo" alt="logo" />  
      </header>

      <div className="menu">

      </div>

      <section >
        <a href="https://learnredux.com/">Learn React</a>
      </section>

      <footer>

      </footer>
    </div> 
  );
}

export default App;

src树

src      
│   App.css
│   App.js
│   App.test.js
│   aws-exports.js
│   index.css
│   index.js
│   logo.svg
│   serviceWorker.js
│   setupTests.js
│   temp
│   
└───images
        logo.png

构建日志

                                 # Starting phase: preBuild
                                 # Executing command: npm ci
2020-09-05T18:33:47.898Z [WARNING]: npm
2020-09-05T18:33:47.898Z [WARNING]: WARN prepare removing existing node_modules/ before installation
2020-09-05T18:33:55.521Z [INFO]: > core-js@2.6.11 postinstall /codebuild/output/src330086095/src/redimdv4/node_modules/babel-runtime/node_modules/core-js
                                 > node -e "try{require('./postinstall')}catch(e){}"
2020-09-05T18:33:55.644Z [INFO]: > fsevents@1.2.13 install /codebuild/output/src330086095/src/redimdv4/node_modules/webpack-dev-server/node_modules/fsevents
                                 > node install.js
2020-09-05T18:33:55.697Z [INFO]: 
2020-09-05T18:33:55.698Z [INFO]: Skipping 'fsevents' build as platform linux is not supported
2020-09-05T18:33:55.713Z [INFO]: > fsevents@1.2.13 install /codebuild/output/src330086095/src/redimdv4/node_modules/watchpack-chokidar2/node_modules/fsevents
                                 > node install.js
2020-09-05T18:33:55.766Z [INFO]: 
2020-09-05T18:33:55.767Z [INFO]: Skipping 'fsevents' build as platform linux is not supported
2020-09-05T18:33:55.837Z [INFO]: > core-js@3.6.5 postinstall /codebuild/output/src330086095/src/redimdv4/node_modules/core-js
                                 > node -e "try{require('./postinstall')}catch(e){}"
2020-09-05T18:33:55.958Z [INFO]: > fsevents@1.2.13 install /codebuild/output/src330086095/src/redimdv4/node_modules/jest-haste-map/node_modules/fsevents
                                 > node install.js
2020-09-05T18:33:56.011Z [INFO]: 
2020-09-05T18:33:56.012Z [INFO]: Skipping 'fsevents' build as platform linux is not supported
2020-09-05T18:33:56.060Z [INFO]: > core-js-pure@3.6.5 postinstall /codebuild/output/src330086095/src/redimdv4/node_modules/core-js-pure
                                 > node -e "try{require('./postinstall')}catch(e){}"
2020-09-05T18:33:56.179Z [INFO]: added 1625 packages in 8.297s
2020-09-05T18:33:56.194Z [INFO]: # Completed phase: preBuild
                                 # Starting phase: build
2020-09-05T18:33:56.194Z [INFO]: # Executing command: npm run build
2020-09-05T18:33:56.362Z [INFO]: > redimdv4@0.1.0 build /codebuild/output/src330086095/src/redimdv4
                                 > react-scripts build
2020-09-05T18:33:57.201Z [INFO]: Creating an optimized production build...
2020-09-05T18:33:58.459Z [INFO]: Failed to compile.
2020-09-05T18:33:58.461Z [INFO]: ./src/index.js
                                 Cannot find file './App.js' in './src'.
2020-09-05T18:33:58.469Z [WARNING]: npm
2020-09-05T18:33:58.470Z [WARNING]: ERR! code ELIFECYCLE
                                    npm ERR! errno 1
                                    npm ERR!
2020-09-05T18:33:58.471Z [WARNING]: redimdv4@0.1.0 build: `react-scripts build`
                                    npm ERR! Exit status 1
                                    npm ERR!
                                    npm ERR! Failed at the redimdv4@0.1.0 build script.
                                    npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2020-09-05T18:33:58.481Z [WARNING]: 
2020-09-05T18:33:58.482Z [WARNING]: npm ERR! A complete log of this run can be found in:
                                    npm ERR!     /root/.npm/_logs/2020-09-05T18_33_58_471Z-debug.log
2020-09-05T18:33:58.482Z [HELP]: Outputting the npm debug log
                                 0 info it worked if it ends with ok
                                 1 verbose cli [ '/root/.nvm/versions/node/v10.16.0/bin/node',1 verbose cli   '/root/.nvm/versions/node/v10.16.0/bin/npm',1 verbose cli   'run',1 verbose cli   'build' ]
                                 2 info using npm@6.9.0
                                 3 info using node@v10.16.0
                                 4 verbose run-script [ 'prebuild','build','postbuild' ]
                                 5 info lifecycle redimdv4@0.1.0~prebuild: redimdv4@0.1.0
                                 6 info lifecycle redimdv4@0.1.0~build: redimdv4@0.1.0
                                 7 verbose lifecycle redimdv4@0.1.0~build: unsafe-perm in lifecycle true
                                 8 verbose lifecycle redimdv4@0.1.0~build: PATH: /root/.nvm/versions/node/v10.16.0/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/codebuild/output/src330086095/src/redimdv4/node_modules/.bin:/usr/local/rvm/gems/ruby-2.4.6/bin:/usr/local/rvm/gems/ruby-2.4.6@global/bin:/usr/local/rvm/rubies/ruby-2.4.6/bin:/usr/local/rvm/bin:/root/.yarn/bin:/root/.config/yarn/global/node_modules/.bin:/root/.nvm/versions/node/v10.16.0/bin:/root/.local/bin:/usr/local/rvm/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
                                 9 verbose lifecycle redimdv4@0.1.0~build: CWD: /codebuild/output/src330086095/src/redimdv4
                                 10 silly lifecycle redimdv4@0.1.0~build: Args: [ '-c','react-scripts build' ]
                                 11 silly lifecycle redimdv4@0.1.0~build: Returned: code: 1  signal: null
                                 12 info lifecycle redimdv4@0.1.0~build: Failed to exec build script
                                 13 verbose stack Error: redimdv4@0.1.0 build: `react-scripts build`
                                 13 verbose stack Exit status 1
                                 13 verbose stack     at EventEmitter.<anonymous> (/root/.nvm/versions/node/v10.16.0/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:301:16)
                                 13 verbose stack     at EventEmitter.emit (events.js:198:13)
                                 13 verbose stack     at ChildProcess.<anonymous> (/root/.nvm/versions/node/v10.16.0/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
                                 13 verbose stack     at ChildProcess.emit (events.js:198:13)
                                 13 verbose stack     at maybeClose (internal/child_process.js:982:16)
                                 13 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:259:5)
                                 14 verbose pkgid redimdv4@0.1.0
                                 15 verbose cwd /codebuild/output/src330086095/src/redimdv4
                                 16 verbose Linux 4.14.186-110.268.amzn1.x86_64
                                 17 verbose argv "/root/.nvm/versions/node/v10.16.0/bin/node" "/root/.nvm/versions/node/v10.16.0/bin/npm" "run" "build"
                                 18 verbose node v10.16.0
                                 19 verbose npm  v6.9.0
                                 20 error code ELIFECYCLE
                                 21 error errno 1
                                 22 error redimdv4@0.1.0 build: `react-scripts build`
                                 22 error Exit status 1
                                 23 error Failed at the redimdv4@0.1.0 build script.
                                 23 error This is probably not a problem with npm. There is likely additional logging output above.
                                 24 verbose exit [ 1,true ]
2020-09-05T18:33:58.484Z [ERROR]: !!! Build failed
2020-09-05T18:33:58.553Z [ERROR]: !!! Non-Zero Exit Code detected
2020-09-05T18:33:58.553Z [INFO]: # Starting environment caching...
2020-09-05T18:33:58.554Z [INFO]: # Environment caching completed
Terminating logging...

解决方法

解决了我自己的问题。代码提交问题。最初是使用app.js创建为纯JavaScript。我将其重命名为App.js并提交了更改。

我注意到在文件浏览器和vs代码中的文件侧栏中,文件名正确显示,但在编辑器选项卡上的名称为app.js。我将其重命名为named.js,将其提交,然后将其重命名为App.js,然后再次提交,然后再推送。

该版本现在可以使用。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


依赖报错 idea导入项目后依赖报错,解决方案:https://blog.csdn.net/weixin_42420249/article/details/81191861 依赖版本报错:更换其他版本 无法下载依赖可参考:https://blog.csdn.net/weixin_42628809/a
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下 2021-12-03 13:33:33.927 ERROR 7228 [ main] o.s.b.d.LoggingFailureAnalysisReporter : *************************** APPL
错误1:gradle项目控制台输出为乱码 # 解决方案:https://blog.csdn.net/weixin_43501566/article/details/112482302 # 在gradle-wrapper.properties 添加以下内容 org.gradle.jvmargs=-Df
错误还原:在查询的过程中,传入的workType为0时,该条件不起作用 &lt;select id=&quot;xxx&quot;&gt; SELECT di.id, di.name, di.work_type, di.updated... &lt;where&gt; &lt;if test=&qu
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct redisServer’没有名为‘server_cpulist’的成员 redisSetCpuAffinity(server.server_cpulist); ^ server.c: 在函数‘hasActiveC
解决方案1 1、改项目中.idea/workspace.xml配置文件,增加dynamic.classpath参数 2、搜索PropertiesComponent,添加如下 &lt;property name=&quot;dynamic.classpath&quot; value=&quot;tru
删除根组件app.vue中的默认代码后报错:Module Error (from ./node_modules/eslint-loader/index.js): 解决方案:关闭ESlint代码检测,在项目根目录创建vue.config.js,在文件中添加 module.exports = { lin
查看spark默认的python版本 [root@master day27]# pyspark /home/software/spark-2.3.4-bin-hadoop2.7/conf/spark-env.sh: line 2: /usr/local/hadoop/bin/hadoop: No s
使用本地python环境可以成功执行 import pandas as pd import matplotlib.pyplot as plt # 设置字体 plt.rcParams[&#39;font.sans-serif&#39;] = [&#39;SimHei&#39;] # 能正确显示负号 p
错误1:Request method ‘DELETE‘ not supported 错误还原:controller层有一个接口,访问该接口时报错:Request method ‘DELETE‘ not supported 错误原因:没有接收到前端传入的参数,修改为如下 参考 错误2:cannot r
错误1:启动docker镜像时报错:Error response from daemon: driver failed programming external connectivity on endpoint quirky_allen 解决方法:重启docker -&gt; systemctl r
错误1:private field ‘xxx‘ is never assigned 按Altʾnter快捷键,选择第2项 参考:https://blog.csdn.net/shi_hong_fei_hei/article/details/88814070 错误2:启动时报错,不能找到主启动类 #
报错如下,通过源不能下载,最后警告pip需升级版本 Requirement already satisfied: pip in c:\users\ychen\appdata\local\programs\python\python310\lib\site-packages (22.0.4) Coll
错误1:maven打包报错 错误还原:使用maven打包项目时报错如下 [ERROR] Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:3.2.0:resources (default-resources)
错误1:服务调用时报错 服务消费者模块assess通过openFeign调用服务提供者模块hires 如下为服务提供者模块hires的控制层接口 @RestController @RequestMapping(&quot;/hires&quot;) public class FeignControl
错误1:运行项目后报如下错误 解决方案 报错2:Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project sb 解决方案:在pom.
参考 错误原因 过滤器或拦截器在生效时,redisTemplate还没有注入 解决方案:在注入容器时就生效 @Component //项目运行时就注入Spring容器 public class RedisBean { @Resource private RedisTemplate&lt;String
使用vite构建项目报错 C:\Users\ychen\work&gt;npm init @vitejs/app @vitejs/create-app is deprecated, use npm init vite instead C:\Users\ychen\AppData\Local\npm-