简体   繁体   English

AWS Amplify:DevTools 无法加载 SourceMap:JSON 中的意外令牌 < position 0

[英]AWS Amplify: DevTools failed to load SourceMap: Unexpected token < in JSON at position 0

I am getting several warnings when loading my website on Google Chrome similar to the following:在 Google Chrome 上加载我的网站时,我收到了一些类似于以下内容的警告:

DevTools failed to load SourceMap: Could not parse content for https://mywebsite.com/static/js/2.abcd1234.chunk.js.map: Unexpected token < in JSON at position 0

My webapp is a React application (create-react-app) deployed on AWS Amplify.我的 webapp 是部署在 AWS Amplify 上的 React 应用程序 (create-react-app)。 I do not get these warnings when running the app locally.在本地运行应用程序时,我没有收到这些警告。 How do I get rid of these warnings?我如何摆脱这些警告?

This is a problem caused by using react-router with AWS amplify.这是将react-router与 AWS amplify 一起使用导致的问题。 See this github issue .请参阅此 github 问题 It suggests adding the following entry in the Rewrites and redirects section of App settings in AWS Amplify:它建议在 AWS Amplify 的 App 设置的Rewrites and redirects部分添加以下条目:

Source address:
</^[^.]+$|\.(?!(css|gif|ico|jpg|js|png|txt|svg|woff|ttf)$)([^.]+$)/>

Target address:
/index.html

Type:
200 (Rewrite)

To solve my problem, I added the map extension to this regex:为了解决我的问题,我向这个正则表达式添加了map扩展名:

Source address:来源地址:

</^[^.]+$|\.(?!(css|gif|ico|jpg|js|png|txt|svg|woff|ttf|map)$)([^.]+$)/>

I checked my Rewrites and redirects settings and it was already configured as per the below answer by "roob" but also had json at the end.我检查了我的重写和重定向设置,它已经按照“roob”的以下答案进行了配置,但最后还有json I removed it to see if that helped.我将其删除以查看是否有帮助。 Either way, I still got the error.无论哪种方式,我仍然得到错误。

More research with a colleague and found another root cause.与同事进行更多研究,发现了另一个根本原因。 Answered here: AWS Amplify error: Failed to parse source map... file: Error: ENOENT: no such file or directory在这里回答: AWS Amplify error: Failed to parse source map... file: Error: ENOENT: no such file or directory

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Babel:使用 AWS Amplify 时无法加载 CSS(意外令牌) - Babel: Can't load CSS (unexpected token) when using AWS Amplify 无法从源加载函数定义:无法从函数源生成清单:SyntaxError:意外的标记“。” - Failed to load function definition from source: Failed to generate manifest from function source: SyntaxError: Unexpected token '.' AWS Amplify 部署失败 - AWS Amplify deployments failing AWS Amplify 构建设置 - AWS Amplify Build Settings “JSON 中的意外令牌}”(通过 Zapier 连接的 Firestore) - "Unexpected token } in JSON" (Firestore connecting through Zapier) 在 AWS Amplify 上构建 React 应用程序在 Amplify 控制台中失败 - Build of React application on AWS Amplify fails in Amplify Console AWS Amplify 错误从 aws-amplify 导入 StorageProvider 类 - AWS Amplify error import StorageProvider class from aws-amplify AWS Amplify UI - 输入确认码后“无法获取登录用户” - AWS Amplify UI - "Failed to get the signed in user" after entering confirmation code AWS Amplify GraphQL 回溯架构 - AWS Amplify GraphQL Recusive Schema 如何使用 AWS Amplify 将关系数据添加到 DataStore? - How to add relational data to DataStore with AWS Amplify?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM