NPM:找不到模块'jest-serializer'(仅在全局安装时)

问题描述 投票:0回答:1

我试图在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然后回来了

+ [email protected]
updated 1 package in 0.498s

所以模块必须存在于我的机器上。为什么react-native bundle找不到它?

编辑

在本地安装jest-serializer解决了这个问题,但是为什么反应本机包脚本找不到包,如果它是全局安装的

node.js react-native npm
1个回答
1
投票

我也遇到了这个问题。

调查结果我发现jest-serializer昨天更新为“24.0.0-alpha.7”。我必须安装以前的版本才能使它正常工作。

我在项目中运行的命令是

npm install [email protected]
© www.soinside.com 2019 - 2024. All rights reserved.