简体   繁体   English

Typescript CRA 与 MSW:无法解析源 map

[英]Typescript CRA with MSW: failed to parse source map

I have created a Create React App application with typescript template build in, then i installed MSW with npm and created files based on MSW install guide.我已经创建了一个使用 typescript 模板构建的 Create React App 应用程序,然后我使用 npm 安装了 MSW,并根据 MSW 安装指南创建了文件。 It's working perfectly for jest, but for browser when im using start script i got a bunch of warnings that are saying:它非常适合开玩笑,但是对于浏览器,当我使用启动脚本时,我收到了一堆警告:

WARNING in ./node_modules/@mswjs/interceptors/lib/utils/uuid.js
Module Warning (from ./node_modules/source-map-loader/dist/cjs.js):
Failed to parse source map from '<ROOT_DIR>\node_modules\@mswjs\interceptors\src\utils\uuid.ts' file: Error: ENOENT: no such file or directory, open '<ROOT_DIR>\node_modules\@mswjs\interceptors\src\utils\uuid.ts'
 @ ./node_modules/@mswjs/interceptors/lib/interceptors/fetch/index.js 167:13-40
 @ ./node_modules/msw/lib/esm/index.js 12:0-76 1568:14-28
 @ ./src/mocks/browser.ts 3:0-34 6:22-33
 @ ./src/index.tsx 8:0-41 10:0-12

and simmilar...和类似的...

I couldn't find any answers so Im asking you for help.我找不到任何答案,所以我向您寻求帮助。

Are you using react-scripts 5 ?你在使用react-scripts 5吗? Webpack 5 used in that version of react-scripts is clashing with msw somehow.该版本的react-scripts中使用的Webpack 5在某种程度上与msw发生冲突。

You have a couple of options for now:你现在有几个选择:

  1. disable source maps by adding a .env file in the root of your project containing GENERATE_SOURCEMAP=false so that you can keep react-scripts 5 ;通过在项目的根目录中添加包含GENERATE_SOURCEMAP=false.env文件来禁用源映射,以便您可以保留react-scripts 5
  2. downgrade react-scripts to v4 .react-scripts降级到v4

More on the github issue posted by kettanaito有关 kettanaito 发布的github问题的更多信息

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

相关问题 解析源失败 map - Failed to parse source map “无法解析源映射” - Electron React 应用程序崩溃 - "Failed to parse source map" - Electron React app crashes 'npm start'上的反应JS奇怪错误无法解析源map - React JS odd Error on 'npm start' Failed to parse source map 无法解析源 map... 错误:ENOENT:没有这样的文件或目录 - Failed to parse source map... Error: ENOENT: no such file or directory CRA + Inversify @inject 模块解析失败:意外字符“@” - CRA + Inversify @inject Module parse failed: Unexpected character '@' 带有 Redux 设置的 TypeScript CRA - TypeScript CRA with Redux setup 无法从@ethersproject 和 xhr2-cookies 文件解析源 map:错误:ENOENT:没有这样的文件或目录 - Failed to parse source map from @ethersproject and xhr2-cookies file: Error: ENOENT: no such file or directory 用 typescript 反应 CRA 不能与 eslint 一起使用 - React CRA with typescript not working with eslint 是什么导致 `WARNING in./node_modules/<package> 模块警告(来自./node_modules/source-map-loader/dist/cjs.js):无法解析源 map</package> - What causes `WARNING in ./node_modules/<package> Module Warning (from ./node_modules/source-map-loader/dist/cjs.js): Failed to parse source map 在 CRA / TypeScript 中导入 mp3 文件 - import mp3 file in CRA / TypeScript
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM