简体   繁体   English

尝试导入错误:'path-to-regexp' 不包含默认导出(导入为 'pathToRegexp')

[英]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.

相关问题 尝试导入错误:“./movieReducer”不包含默认导出(导入为“movieReducer”) - Attempted import error: './movieReducer' does not contain a default export (imported as 'movieReducer') 尝试导入错误:“./components”不包含默认导出(导入为“App”) - Attempted import error: './components' does not contain a default export (imported as 'App') index.js 尝试导入错误:“./App”不包含默认导出(导入为“App”) - index.js attempted import error: './App' does not contain a default export (imported as 'App') ./src/index.js 尝试导入错误:“./App.js”不包含默认导出(导入为“App”) - ./src/index.js Attempted import error: './App.js' does not contain a default export (imported as 'App') 尝试导入错误:“firebase/app”不包含默认导出(导入为“firebase”) - Attempted import error: 'firebase/app' does not contain a default export (imported as 'firebase') [React.js] 尝试导入错误:'./registerServiceWorker' 不包含默认导出(导入为 'registerServiceWorker') - [React.js]Attempted import error: './registerServiceWorker' does not contain a default export (imported as 'registerServiceWorker') 尝试导入错误:“uuid”在 React 中不包含默认导出(导入为“uuid”) - Attempted import error: 'uuid' does not contain a default export (imported as 'uuid') In React 尝试导入错误:“./components/headerComponent/header”不包含默认导出(导入为“标题”) - Attempted import error: './components/headerComponent/header' does not contain a default export (imported as 'Header') 尝试导入错误:“react-table”不包含默认导出(导入为“ReactTable”) - Attempted import error: 'react-table' does not contain a default export (imported as 'ReactTable') React JS 尝试导入错误:'./Pathfinder/Pathfinder' 不包含默认导出(导入为 'Pathfinder') - React JS Attempted import error: './Pathfinder/Pathfinder' does not contain a default export (imported as 'Pathfinder')
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM