【发布时间】:2018-12-12 16:33:14
【问题描述】:
我正在尝试在 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
所以该模块必须存在于我的机器上。为什么 react-native bundle 找不到呢?
编辑
在本地安装jest-serializer解决了这个问题,但是如果全局安装了react-native bundle脚本为什么找不到包
【问题讨论】:
标签: node.js react-native npm