我安装了yarn add react-router-dom
,并且在导入"react-router-dom"
时显示错误
错误消息
./node_modules/react-router-dom/node_modules/warning/warning.js
Error: ENOENT: no such file or directory, open '/Users/krittiyaclark/Documents/my-portfolio-react/node_modules/react-router-dom/node_modules/warning/warning.js'
我的package.json
{
"name": "my-portfolio-react",
"version": "0.1.0",
"private": true,
"dependencies": {
"gulp": "^3.9.1",
"gulp-changed": "^3.2.0",
"gulp-clean-css": "^4.0.0",
"gulp-rename": "^1.4.0",
"gulp-sass": "^4.0.2",
"gulp-uglify": "^3.0.1",
"react": "^16.7.0",
"react-dom": "^16.7.0",
"react-mdl": "^1.11.0",
"react-router-dom": "^4.3.1",
"react-scripts": "2.1.3"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"browserslist": [
">0.2%",
"not dead",
"not ie <= 11",
"not op_mini all"
]
}
请帮助!我卡了很久。 谢谢!
答案 0 :(得分:1)
一旦遇到此问题,我就尝试停止进程浏览器中的所有Node进程。另外,请尝试从命令行工具安装软件包。
这为我解决了这个问题。
答案 1 :(得分:0)
我刚刚使用create-react-app
创建了一个应用,并像您一样添加了react-router-dom
,一切正常,我唯一的区别是某些软件包版本:
{
"name": "quicktest",
"version": "0.1.0",
"private": true,
"dependencies": {
"react": "^16.8.4",
"react-dom": "^16.8.4",
"react-router-dom": "^4.3.1",
"react-scripts": "2.1.8"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": [
">0.2%",
"not dead",
"not ie <= 11",
"not op_mini all"
]
}
尝试运行npm update来更新它们并重新启动您的应用。
显然,react-router-dom
的版本4.3.1修复了与此错误相关的某些问题(奇怪的是,您使用的版本):
答案 2 :(得分:0)
如果尚未运行Python 3.7.3 (v3.7.3:ef4ec6ed12, Mar 25 2019, 21:26:53) [MSC v.1916 32 bit
(Intel)] on win32
Type "help", "copyright", "credits" or "license()" for more information.
>>>
RESTART: C:\Users\Henryk\Documents\Selenium sample
project\SeleniumSampleProject.py
Traceback (most recent call last):
File "C:\Users\Henryk\Documents\Selenium sample
project\SeleniumSampleProject.py", line 2, in <module>
from selenium.webdriver.comma.keys import Keys
ModuleNotFoundError: No module named 'selenium.webdriver.comma'
>>>
,则需要运行它来安装所有依赖项。如果您以前安装过它们,请从您的项目目录中删除yarn install
目录(.cache
),然后再次运行rm -rf
。