npm test / jest无法正常工作

时间:2017-10-24 18:54:24

标签: reactjs npm jest

我正在尝试使用react / jest进行测试。当我执行npm test / jest时,我收到以下错误:

 > @ test /Users/suparnasoman/Downloads/create-react-app-master
> node packages/react-scripts/scripts/test.js --env=jsdom

module.js:471
    throw err;
    ^

Error: Cannot find module 'jest'
    at Function.Module._resolveFilename (module.js:469:15)
    at Function.Module._load (module.js:417:25)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/Users/suparnasoman/Downloads/create-react-app-master/packages/react-scripts/scripts/test.js:26:14)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
npm ERR! Test failed.  See above for more details.
npm WARN Local package.json exists, but node_modules missing, did you mean to install?

2 个答案:

答案 0 :(得分:1)

  1. 检查npm包是否已成功安装。
  2. 如果安装成功,请检查是否全局/本地安装。
  3. 如果是本地的,您可能需要提供绝对路径node_modules/bin/jest

答案 1 :(得分:0)

似乎缺少了jest模块,你是否按照Chase提到的那样尝试了npm --save install jestnpm install