首页 > 解决方案 > Jest 期望为 Node 构建本机依赖项,​​但我的依赖项是为 Electron 构建的 - 我能做什么?

问题描述

如何解决 Jest 想要为 node 构建本机依赖项,​​但我为 Electron 构建它们(使用npm rebuild --runtime=electron --target=2.0.2 --disturl=https://atom.io/download/atom-shell --build-from-source)的情况

如何让 Jest 使用为 构建的模块Electron,或同时管理两者?

节点 8.11.3 纱线 1.7.0 NPM 5.6.0

warning package.json: License should be a valid SPDX license expression
$ jest --no-cache --colors
 FAIL  app/redux/sagas/things/__tests__/database.test.js
  ● Test suite failed to run

    Failed to load gRPC binary module because it was not installed for the current system
    Expected directory: node-v57-win32-x64-unknown
    Found: [electron-v2.0-win32-x64-unknown]
This problem can often be fixed by running "npm rebuild" on the current system
Original error: Cannot find module 'C:\projects\myApp\app\node_modules\grpc\src\node\extension_binary\node-v57-win32-x64-unknown\grpc_node.node' from 'grpc_extension.js'


 > 1 | import firebase from 'firebase';
    | ^
  2 | import '@firebase/storage';
  3 | import ReduxSagaFirebase from 'redux-saga-firebase';
  4 | import validate from 'uuid-validate';

  at Object.<anonymous> (app/node_modules/grpc/src/grpc_extension.js:53:17)
  at Object.<anonymous> (app/node_modules/grpc/src/client_interceptors.js:145:12)
  at Object.<anonymous> (app/node_modules/grpc/src/client.js:37:27)
  at Object.<anonymous> (app/node_modules/grpc/index.js:30:14)
  at Object.<anonymous> (app/node_modules/@firebase/firestore/dist/index.node.cjs.js:10:12)
  at Object.<anonymous> (app/node_modules/firebase/dist/index.node.cjs.js:9:1)
  at Object.<anonymous> (app/redux/sagas/rsf.js:1:1)
  at Object.<anonymous> (app/redux/sagas/sagaHelpers.js:19:1)
  at Object.<anonymous> (app/redux/sagas/things/database/general.js:6:1)
  at Object.<anonymous> (app/redux/sagas/things/database.js:7:1)
  at Object.<anonymous> (app/redux/sagas/things/__tests__/database.test.js:2:1)

标签: javascriptnode.jselectronjestjsgrpc

解决方案


推荐阅读