英文:
firebase functions Build failed: npm ERR! code EBADPLATFORM
问题
当我尝试将函数部署到Firebase云函数时,我遇到了以下错误:
functions: 更新 Node.js 16 函数 MGSERVER(us-central1)...
构建失败:npm ERR! 代码 EBADPLATFORM
npm ERR! notsup 不支持的平台 @next/swc-darwin-arm64@13.3.0:期望 {"os":"darwin","arch":"arm64"} (当前:{"os":"linux","arch":"x64"})
npm ERR! notsup 有效的操作系统:darwin
npm ERR! notsup 有效的架构:arm64
npm ERR! notsup 实际操作系统:linux
npm ERR! notsup 实际架构:x64
npm ERR! 可以在以下位置找到此运行的完整日志:
npm ERR! /www-data-home/.npm/_logs/2023-04-19T14_09_08_794Z-debug-0.log; 错误ID:beaf8772
部署函数时出现以下函数的错误:
MGSERVER(us-central1)
i functions: 清理构建文件...
错误:部署函数时出现错误
无论我尝试什么都会失败,即使尝试将firebase-tools降级到11.0.0或任何其他版本也会失败:
npm install -g firebase-tools@11.0.0
运行 `firebase tools --version` 后会显示 `11.18.0`
我的Node版本是:`16.20.0`
是否有人有解决方案?因为现在我无法更新任何函数了...
<details>
<summary>英文:</summary>
when i try to deploy a functions to firebase cloud functions i get the next error:
functions: updating Node.js 16 function MGSERVER(us-central1)...
Build failed: npm ERR! code EBADPLATFORM
npm ERR! notsup Unsupported platform for @next/swc-darwin-arm64@13.3.0: wanted {"os":"darwin","arch":"arm64"} (current: {"os":"linux","arch":"x64"})
npm ERR! notsup Valid OS: darwin
npm ERR! notsup Valid Arch: arm64
npm ERR! notsup Actual OS: linux
npm ERR! notsup Actual Arch: x64
npm ERR! A complete log of this run can be found in:
npm ERR! /www-data-home/.npm/_logs/2023-04-19T14_09_08_794Z-debug-0.log; Error ID: beaf8772
Functions deploy had errors with the following functions:
MGSERVER(us-central1)
i functions: cleaning up build files...
Error: There was an error deploying functions
All the things i try will fail, even when try do downgrade firebase-tools to 11.0.0 or any other version with:
npm install -g firebase-tools@11.0.0
After I run `firebase tools --version` it will say `11.18.0`
my node version is: `16.20.0`
does any one has a solution because now i can't update any functions anymore..
</details>
# 答案1
**得分**: 1
你可以在项目的根目录下创建一个名为`.babelrc`的文件,并添加以下内容:
```json
{
"presets": [
"next/babel"
]
}
这将指示它跳过使用基于Rust的编译器,如在failed-loading-swc中讨论的那样。那里还讨论了其他选项,比如删除你的package-lock.json
和node_modules
目录,然后使用--optional
标志重新安装swc:
npm install --save next@^13.3.0 --include=optional
但这是一种极端的选择,并不能保证在像Cloud Build环境这样的外部构建系统上能正常工作。
英文:
You can create a file at the root of your project named .babelrc
and add the following contents:
{
"presets": [
"next/babel"
]
}
This will instruct it to skip using the Rust-based compiler as discussed at failed-loading-swc. There are other options discussed there as well, such as removing your package-lock.json
and your node_modules
directory and reinstalling swc with the --optional
flag:
npm install --save next@^13.3.0 --include=optional
But this is the nuclear option and not guaranteed to work on external build systems like the Cloud Build environment.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论