【问题标题】:import "react-toastify/dist/ReactToastify.css";导入 \"react-toastify/dist/ReactToastify.css\";
【发布时间】:2022-12-17 10:13:05
【问题描述】:

C:\Users\User\Documents\GitHub\zampliasurveys_frontend\node_modules\react-toastify\dist\ReactToastify.css:1 ({"Object.":function(module,exports,require,__dirname,__filename,jest){:root { ^

SyntaxError: Unexpected token ':'

   6 | import { Footer } from "components/Footer/Footer";
   7 | import { ToastContainer } from "react-toastify";
>  8 | import "react-toastify/dist/ReactToastify.css";
     | ^
   9 |
  10 | export const Layout = () => {
  11 |   return (

  at Runtime.createScriptFromCode (node_modules/react-scripts/node_modules/jest-runtime/build/index.js:1728:14)
  at Object.<anonymous> (src/pages/Layout/index.tsx:8:1)
  at Object.<anonymous> (src/AppRoutes.tsx:9:1)
  at Object.<anonymous> (src/App.tsx:1:1)
  at Object.<anonymous> (src/__test__/App.test.tsx:3:1)

【问题讨论】:

    标签: javascript reactjs typescript unit-testing jestjs


    【解决方案1】:

    确保你已经安装了所有依赖项.. 做完就跑

    npm 安装

    在终端

    【讨论】:

    • 感谢您的建议!
    【解决方案2】:

    只需要在 package.json 中添加 foolowing 配置,在 dev 依赖项下面。

    "transformIgnorePatterns": [
          "node_modules/(?!(axios|react-toastify))"
    ],
    

    //This the way how you can make eslint ignore syntax related to a dependency

    【讨论】:

      猜你喜欢
      • 2019-11-19
      • 2020-03-15
      • 1970-01-01
      • 1970-01-01
      • 2022-08-05
      • 2023-01-24
      • 1970-01-01
      • 2022-08-04
      • 2022-01-18
      相关资源
      最近更新 更多