这有效
import Component from '../component.jsx';
抛出错误
import Component from '/client/modules/account_details/components/component.jsx';
Module not found: Error: Cannot resolve 'file' or 'directory'
我的一些组件在 import 语句中具有绝对路径,这也打破了故事。 除了做../../../../
等之外,还有其他解决方法吗?
我尝试使用https://github.com/mantrajs/babel-root-slash-import但开始得到
添加该包和.babelrc
文件后Uncaught SyntaxError: Unexpected token import
问题
{
"plugins": [
"babel-root-slash-import"
]
}
能够解决这个问题
{
"presets": ["es2015", "react"],
"plugins": [
"babel-root-slash-import"
]
}
{
"presets": ["es2015", "react"],
"plugins": [
[
"babel-root-slash-import", {
"rootPathSuffix": "src/"
}
]
]
}
像这样的东西?
因为这不起作用
这也是从 create react app 覆盖 .babelrc 的默认配置吗?