简体   繁体   English

eslint:分析错误:导入期间出现意外令牌

[英]eslint: Parsing error: Unexpected token during import

In a ReactJS app, I have an index.js file with the following imports: 在ReactJS应用程序中,我有一个带有以下导入的index.js文件:

export MainContainer from './Main/MainContainer';
export AboutContainer from './About/AboutContainer';

When I run ESLINT, I get the following error: 运行ESLINT时,出现以下错误:

error  Parsing error: Unexpected token MainContainer

The error message is not referencing any of the eslint rules set up in .eslintrc.json. 错误消息未引用.eslintrc.json中设置的任何eslint规则。 The app runs fine in Chrome with no console errors. 该应用程序在Chrome中运行正常,没有控制台错误。 Why is eslint throwing the error? 为什么eslint抛出错误?

You have export instead of import while trying to import. 尝试导入时,您已导出而不是导入。 Try: 尝试:

import MainContainer from './Main/MainContainer';
import AboutContainer from './About/AboutContainer';

;) ;)

If you're trying to re-export components, you'll need the braces: 如果您尝试重新导出组件,则需要使用花括号:

export { MainContainer } from './Main/MainContainer';
export { AboutContainer } from './About/AboutContainer';

If it's re-exporting default exports: 如果要重新导出默认导出,请执行以下操作:

export { default as MainContainer } from './Main/MainContainer';
export { default as AboutContainer } from './About/AboutContainer';

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

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