首页 > 解决方案 > 找不到模块:错误:无法解析“cypress-react-selector”

问题描述

我正在尝试使用@cypress/react并按照安装说明进行操作。此外,我还安装了赛普拉斯测试库以使用赛普拉斯的测试库扩展。

启动柏树时,我收到以下错误消息:

./node_modules/@cypress/react/support/index.js
Module not found: Error: Can't resolve 'cypress-react-selector' in '/home/developer/project/example/webapp/board-ui/node_modules/@cypress/react/support'
resolve 'cypress-react-selector' in '/home/developer/project/example/webapp/board-ui/node_modules/@cypress/react/support'
  Parsed request is a module
  using description file: /home/developer/project/example/webapp/board-ui/node_modules/@cypress/react/package.json (relative path: ./support)
    Field 'browser' doesn't contain a valid alias configuration
    Looked for and couldn't find the file at the following paths:
[/home/developer/project/example/webapp/board-ui/node_modules/@cypress/react/support/node_modules]
[/home/developer/project/example/webapp/board-ui/node_modules/@cypress/node_modules]  

我必须安装 cypress-react-selector 吗?

标签: node.jsreactjscypress

解决方案


您可以只安装缺少的包cypress-react-selector

npm i --save cypress-react-selector

我不确定它是否应该与@cypress/react 或 Cypress 测试库一起安装,如果是这样,那么值得重新安装它们并在安装过程中注意错误消息。


推荐阅读