[英]Attempted import error: 'path-to-regexp' does not contain a default export (imported as 'pathToRegexp')
Failed to compile the react-router.无法编译反应路由器。 This happend after installing path-to-regexp
这发生在安装路径到正则表达式之后
./node_modules/react-router/esm/react-router.js
./node_modules/react-router/esm/react-router.js
Attempted import error: 'path-to-regexp' does not contain a default export (imported as 'pathToRegexp').
This error occurred during the build time and cannot be dismissed.此错误发生在构建期间,无法消除。
For me, this occurred as my path-to-regex had been updated to newer version.对我来说,这是因为我的正则表达式路径已更新到较新版本。
I solved this by simply reverting back to the old version of path-to-regex.To do that simply run this: npm i path-to-regexp@2.4.0 --save
我通过简单地恢复到旧版本的路径到正则表达式来解决这个问题。为此,只需运行以下命令:
npm i path-to-regexp@2.4.0 --save
Instead of downgrading to an old version, just change the way you import: from:不要降级到旧版本,只需更改导入方式: from:
import pathToRegexp from 'path-to-regexp';
to到
import { pathToRegexp } from 'path-to-regexp';
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.