【问题标题】:npm test/ jest not workingnpm 测试/开玩笑不工作
【发布时间】:2018-04-05 16:39:06
【问题描述】:

我正在尝试使用 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?

【问题讨论】:

  • 先运行npm install

标签: reactjs npm jestjs


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

【讨论】:

    【解决方案2】:

    似乎缺少 jest 模块,您是否尝试过 npm --save install jestnpm install 作为 Chase 提到的?

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2022-10-21
      • 2021-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-06-11
      • 1970-01-01
      • 2020-02-06
      相关资源
      最近更新 更多