简体   繁体   English

REACT JEST错误无法从'jest-expect.js'中找到模块'jest-matchers'

[英]REACT JEST error Cannot find module 'jest-matchers' from 'jest-expect.js'

When running tests getting the following error: 运行测试时出现以下错误:

Cannot find module 'jest-matchers' from 'jest-expect.js' 无法从'jest-expect.js'找到模块'jest-matchers'

  at Resolver.resolveModule (node_modules/jest-resolve/build/index.js:169:17)

Any ideas??? 有任何想法吗???

I'm using: 我正在使用:

node@6.3.1
npm@4.0.5
jest@19.0.2
jest-matchers@19.0.0

您可以尝试在项目的文件夹上运行npm ls ,以查看缺少的依赖项

尝试删除node_modules文件夹并再次执行npm install

Add node_modules to moduleDirectories . node_modules添加到moduleDirectories

If you have a jest.config.js add it there, 如果你有一个jest.config.js在那里添加,

// jest.config.js
module.exports = {
  verbose: true,
  moduleDirectories: ["node_modules"]
};

otherwise should be added to package.json 否则应该添加到package.json

"jest":{
  ...
  "moduleDirectories": ["node_modules"]
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何解决 React 项目中的酶/Jest 错误“无法从 'react-router.js' 中找到模块 'react'” - How to solve an Enzyme/Jest error "Cannot find module 'react' from 'react-router.js'" in a React project 反应故事书jest快照导致错误无法从'node.js'找到模块'../../package' - react storybook jest snapshots leads to an error Cannot find module '../../package' from 'node.js' 玩笑失败 React 16 升级后无法从“ReactShallowRenderer.js”中找到模块“react/lib/React” - Jest fails Cannot find module 'react/lib/React' from 'ReactShallowRenderer.js' after React 16 upgrade 开玩笑找不到模块 - Jest cannot find module Jest失败并出现错误:无法找到模块'react / lib / ReactComponentTreeHook' - Jest fails with error: Cannot find module 'react/lib/ReactComponentTreeHook' 用酶和玩笑测试 React 给出错误无法从“index.js”中找到模块“@babel/polyfill/lib/noConflict” - Testing React with enzyme and jest giving error Cannot find module '@babel/polyfill/lib/noConflict' from 'index.js' 开玩笑找不到模块@env React Native - Jest cannot find module @env React Native 在 Next.js 上使用 jest 找不到模块错误 - Cannot find module error using jest on Next.js 开玩笑找不到模块反应位置 - Jest Cannot Find Module react-location 开玩笑测试:无法从'Link.react.js'中找到模块'../Link.react' - Jest test: Cannot find module '../Link.react' from 'Link.react.js'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM