javascript - 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)
解决方案
推荐阅读
- authentication - 工业环境中 Web 应用身份验证的最佳实践
- gpt - 在linux中,fsck gpt外置硬盘失败
- docker - 如何修复 docker-compose.yml?预期的
, 但发现 ' ' - sql - Bigquery 中的 STRING_AGG
- angular - 如果填充了 matInput 如何更改它的颜色
- java - 如何刷新打开活动的片段,然后将活动关闭回片段
- python - 如何使用 Python 创建 JKS 或 P12 密钥库
- firebase - 从 firebase Firestore 下载数据到 Flutter
- javascript - 获取所需类型“String!”的错误变量“$name” 没有提供。从 React-Apollo 触发 Graphql 请求
- c# - 使用 Entity Framework Core 扩展 EFCore Bulk 扩展的批量读取问题 - 无法让批量读取工作