当我试图运行我的TypeScript应用程序时,我会得到这个错误:
Namespace '"C:/DevTools/git/motor.ui/node_modules/history/index"' has no exported member 'LocationState'.
这是我的package.json
{
"name": "motor.ui",
"version": "0.1.0",
"private": true,
"dependencies": {
"@digital/react-avis-atom": "^2.4.0",
"@elastic/apm-rum": "^5.6.1",
"@types/react-router-dom": "^4.3.0",
"axios": "^0.18.0",
"classnames": "^2.2.6",
"moment": "^2.22.2",
"query-string": "5",
"react": "^16.4.2",
"react-dom": "^16.4.2",
"react-moment": "^0.7.9",
"react-router-dom": "^4.4.0-alpha.1",
"react-scripts-avis": "2.16.75"
},
"scripts": {
"start": "react-scripts-avis start",
"build": "sh -ac '. ./.env.${REACT_APP_ENV}; react-scripts-avis build'",
"build:sys": "REACT_APP_ENV=sys yarn run build",
"build:uat": "REACT_APP_ENV=uat yarn run build",
"build:production": "REACT_APP_ENV=production yarn run build",
"test": "react-scripts-avis test --env=jsdom",
"eject": "react-scripts-avis eject",
"lint": "yarn tslint",
"tslint": "tslint -t stylish -c tslint.json -e '**/node_modules/**/*' 'src/**/*.+(ts|tsx)'",
"tslint-fix": "yarn tslint --fix",
"tslint-staged": "LIST=`git diff-index --cached --name-only HEAD | grep .*\\\\.ts | grep -v json`; if [[ ! -z ${LIST} ]]; then tslint -t stylish $LIST; else echo 'empty'; fi",
"analyze": "source-map-explorer build/static/js/main.*",
"uploadSrcMap": "NODE_TLS_REJECT_UNAUTHORIZED=0 node ./tools/sourceMapUploader.js"
},
"coverageThreshold": {
"global": {
"branches": 90,
"functions": 90,
"lines": 90,
"statements": 90
}
},
"devDependencies": {
"@types/classnames": "^2.2.6",
"@types/enzyme": "^3.1.13",
"@types/enzyme-adapter-react-16": "^1.0.3",
"@types/jest": "^23.3.1",
"@types/node": "^10.9.4",
"@types/react": "^16.4.13",
"@types/react-dom": "^16.0.7",
"@types/webpack-env": "^1.13.6",
"axios-mock-adapter": "^1.15.0",
"enzyme": "^3.5.0",
"enzyme-adapter-react-16": "^1.3.1",
"source-map-explorer": "^1.6.0",
"typescript": "^3.0.3"
},
"homepage": "."
}
我该怎么解决这个问题?
发布于 2022-04-05 07:23:30
您的@types/react-router-dom
版本太旧了,请尝试升级到5.x
版本。
https://stackoverflow.com/questions/70944808
复制相似问题