expo update 破坏了 npm install
我正在慢慢将我的 Expo 项目从 36.0.0 升级到 40.0.0。我通过一次更新一个版本来确保应用程序不会受到任何影响。但是,我遇到了一个问题,无法执行此操作。
每当我运行时:
expo update
一切都运行正常,只是无法安装节点模块。这是完整的日志:
$ expo update
Warning! Your git working tree is dirty.
It's recommended to commit all your changes before proceeding, so you can revert the changes made by this command if necessary.
√ Would you like to proceed? ... yes
√ You are currently using SDK 36.0.0. Would you like to update to the latest version, 40.0.0? ... no
√ Choose a SDK version to upgrade to: » 37.0.0
√ Would you like to upgrade the Expo app in the Android emulator? ... no
√ Installed expo@^37.0.0
√ Removed deprecated sdkVersion field from app.json.
√ No additional changes necessary to app.json config.
× Failed to upgrade JavaScript dependencies: @react-native-community/[email protected] expo-av@~8.1.0 expo-camera@~8.2.0 expo-image-picker@~8.1.0 expo-keep-awake@~8.1.0 expo-linear-gradient@~8.1.0 expo-media-library@~8.1.0 expo-permissions@~8.1.0 expo-secure-store@~8.1.0 expo-sensors@~8.1.0 react-native-gesture-handler@~1.6.0 react-native-reanimated@~1.7.0 react-native-screens@~2.2.0 [email protected] [email protected] [email protected] @react-native-community/[email protected] [email protected] react-native@https://github.com/expo/react-native/archive/sdk-37.0.1.tar.gz [email protected] [email protected] react-native-web@^0.11.7
√ Updated known packages to compatible versions.
√ Removed package-lock.json and deleted node_modules.
× Running npm install failed. Please check npm-error.log for more information.
√ Cleared packager cache.
👏 Automated upgrade steps complete.
...but this doesn't mean everything is done yet!
✅ The following packages were updated:
@react-native-community/netinfo, expo-av, expo-camera, expo-image-picker, expo-keep-awake, expo-linear-gradient, expo-media-library, expo-permissions, expo-secure-store, expo-sensors, react-native-gesture-handler, react-native-reanimated, react-native-screens, react-native-svg, react-native-webview, react-native-safe-area-context, @react-native-community/masked-view, firebase, react-native, react, react-dom, react-native-web, babel-preset-expo, expo
🚨 The following packages were not updated. You should check the READMEs for those repositories to determine what version is compatible with your new set of packages:
Base64, lighten-darken-color, native-base, react-devtools, react-native-android-wheel-picker, react-native-auto-height-image, react-native-collapsible, react-native-drag-sort, react-native-elements, react-native-keyboard-aware-scroll-view, react-native-popup-menu, react-native-progress, react-native-progress-circle, react-native-render-html, react-native-snap-carousel, react-native-sound,
react-native-svg-charts, react-navigation, react-navigation-stack, react-navigation-tabs, superagent, uuid, @babel/core
Please refer to the release notes for information on any further required steps to update and information about breaking changes:
https://dev.to/expo/expo-sdk-37-is-now-available-69g
我尝试通过运行 npm install 手动修复此问题,但最终出现此错误:
gyp ERR! build error
gyp ERR! stack Error: `C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin\MSBuild.exe` failed with exit code: 1
gyp ERR! stack at ChildProcess.onExit (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\build.js:194:23)
gyp ERR! stack at ChildProcess.emit (events.js:315:20)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:277:12)
gyp ERR! System Windows_NT 10.0.19042
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "build" "--fallback-to-build" "--library=static_library" "--module=C:\\Programming\\lcf-routine-mobile\\node_modules\\grpc\\src\\node\\extension_binary\\node-v83-win32-x64-unknown\\grpc_node.node" "--module_name=grpc_node" "--module_path=C:\\Programming\\lcf-routine-mobile\\node_modules\\grpc\\src\\node\\extension_binary\\node-v83-win32-x64-unknown" "--napi_version=7" "--node_abi_napi=napi" "--napi_build_version=0" "--node_napi_label=node-v83"
gyp ERR! cwd C:\Programming\lcf-routine-mobile\node_modules\grpc
gyp ERR! node -v v14.15.2
gyp ERR! node-gyp -v v5.1.0
gyp ERR! not ok
node-pre-gyp ERR! build error
node-pre-gyp ERR! stack Error: Failed to execute 'C:\Program Files\nodejs\node.exe C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js build --fallback-to-build --library=static_library --module=C:\Programming\lcf-routine-mobile\node_modules\grpc\src\node\extension_binary\node-v83-win32-x64-unknown\grpc_node.node --module_name=grpc_node --module_path=C:\Programming\lcf-routine-mobile\node_modules\grpc\src\node\extension_binary\node-v83-win32-x64-unknown --napi_version=7 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v83' (1)
node-pre-gyp ERR! stack at ChildProcess.<anonymous> (C:\Programming\lcf-routine-mobile\node_modules\grpc\node_modules\node-pre-gyp\lib\util\compile.js:83:29)
node-pre-gyp ERR! stack at ChildProcess.emit (events.js:315:20)
node-pre-gyp ERR! stack at maybeClose (internal/child_process.js:1048:16)
node-pre-gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:288:5)
node-pre-gyp ERR! System Windows_NT 10.0.19042
node-pre-gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Programming\\lcf-routine-mobile\\node_modules\\grpc\\node_modules\\node-pre-gyp\\bin\\node-pre-gyp" "install" "--fallback-to-build" "--library=static_library"
node-pre-gyp ERR! cwd C:\Programming\lcf-routine-mobile\node_modules\grpc
node-pre-gyp ERR! node -v v14.15.2
node-pre-gyp ERR! node-pre-gyp -v v0.14.0
node-pre-gyp ERR! not ok
Failed to execute 'C:\Program Files\nodejs\node.exe C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js build --fallback-to-build --library=static_library --module=C:\Programming\lcf-routine-mobile\node_modules\grpc\src\node\extension_binary\node-v83-win32-x64-unknown\grpc_node.node --module_name=grpc_node --module_path=C:\Programming\lcf-routine-mobile\node_modules\grpc\src\node\extension_binary\node-v83-win32-x64-unknown --napi_version=7 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v83' (1)
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.2.7 (node_modules\jest-haste-map\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
npm WARN @codler/[email protected] requires a peer of react-native@>=0.63.0 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of eslint@>=3.14.1 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of react-native@^0.63.0 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of react-native-svg@^6.2.1||^7.0.3 but none is installed. You must install peer dependencies yourself.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] install: `node-pre-gyp install --fallback-to-build --library=static_library`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Yaad\AppData\Roaming\npm-cache\_logs\2020-12-17T23_45_55_412Z-debug.log
我多次重新安装了 NodeJS,但我不认为问题出在这里,因为在运行 expo update 之前 npm install 运行完全正常。有人能帮我吗?
我的 npm 安装在
expo upgrade
时从 SDK 40 升级到 41 时中断了。
经过一番研究,我发现这是 npm 版本 7.xx 的一个错误。
降级到 6.x 后,
expo upgrade
工作正常。
运行:
npm install
[email protected]
-g
然后重试:
expo upgrade
现在您可以根据需要再次安装最新的 npm 版本。
也许这对某些人有帮助✌️
非常丑陋的解决方案,但是我通过将更新之前的 package-lock.json 复制粘贴到更新后的项目文件夹中(因为 expo upgrade 会删除它)来使 npm install 正常工作
这里有一些我尝试过但出现相同错误的其他方法,但也许它们对你有用:
来自官方博客文章: https://dev.to/expo/expo-sdk-37-is-now-available-69g
尝试使用
npm i -g expo-cli
更新 expo-cli,并尝试运行“expo upgrade”而不是“expo update”
还尝试运行
npm install --package-lock-only
然后正常npm 安装
尝试执行以下步骤,至少对我来说是有效的。
在您的项目目录中执行此操作:
步骤 1:
npm config set legacy-peer-deps true
步骤 2:
rm -rf node_modules
步骤 3:
npm install expo
步骤 4:
expo update