简体   繁体   中英

“Unexpected token import” error in react-router-dom navlink dependency

When I am trying to test the default test of create-react-app. It gave me an error of ES6 compilation of ES6 import. I don't have any transpiler like babel in my code. Do I need to use .babelrc to transpile the code?

FAIL src\\app\\App.test.js ● Test suite failed to run

C:\Users\ritesh\Desktop\AelerUI\aeler-web\node_modules\react-router-dom\es\NavLink.js:7
import React from "react";
^^^^^^
SyntaxError: Unexpected token import

  at ScriptTransformer._transformAndBuildScript (node_modules/jest-runtime/build/ScriptTransformer.js:289:17)
  at Object.<anonymous> (src/component/LeftNavbar/LeftNavbar.js:7:16)
  at Object.<anonymous> (src/App.js:5:19)

Did you use npm i before ? Maybe packages aren't donwloaded.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM