我试图在android模拟器上运行一个react-native项目,但是在我让它正常运行之前,我需要运行以下命令:
react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res
我在this question处收到了此命令,因为那里遇到了描述的问题。昨天可以使用,但是今天早上我创建了一个新项目,现在运行命令时,以下堆栈跟踪出现了错误:
Error: Cannot find module 'jest-serializer'
at Function.Module._resolveFilename (module.js:547:15)
at Function.Module._load (module.js:474:25)
at Module.require (module.js:596:17)
at require (internal/module.js:11:18)
at _load_jestSerializer (/Users/jareddembrun/Documents/Rot3/ReactNative/MyTechLoungeReactNativeMobileApp/node_modules/jest-haste-map/build/index.js:164:52)
at HasteMap._persist (/Users/jareddembrun/Documents/Rot3/ReactNative/MyTechLoungeReactNativeMobileApp/node_modules/jest-haste-map/build/index.js:781:25)
at _buildPromise._buildFileMap.then.then.hasteMap (/Users/jareddembrun/Documents/Rot3/ReactNative/MyTechLoungeReactNativeMobileApp/node_modules/jest-haste-map/build/index.js:425:16)
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:188:7)
我跑了npm install -g jest-serializer
然后回来了
+ jest-serializer@23.0.1
updated 1 package in 0.498s
因此该模块必须存在于我的机器上。为什么本地反应堆很难找到它?
在本地安装jest-serializer
可以解决此问题,但是如果本地安装的包脚本是全局安装的,为什么为什么本地包脚本无法找到
答案 0 :(得分:1)
我也刚遇到这个问题。
查看它,我发现jest-serializer昨天已更新为“ 24.0.0-alpha.7”。 我必须安装以前的版本才能使其正常工作。
我在项目中运行的命令是
npm install jest-serializer@24.0.0-alpha.6