【问题标题】:Vercel React.js Deployment: Cannot find module: 'firebase'. Make sure this package is installedVercel React.js 部署:找不到模块:'firebase'。确保已安装此软件包
【发布时间】:2022-01-11 19:16:03
【问题描述】:

我向 Vercel 部署了一个使用 firebase 的 React 应用。构建以状态码 1 退出。 我已经使用:“npm install firebase”安装了firebase,它在本地环境中运行良好。可能的错误是什么?

Creating an optimized production build...
Failed to compile.
./src/firebase.js
Cannot find module: 'firebase'. Make sure this package is installed.
You can install this package by running: npm install firebase.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! neozon@0.1.0 build: `react-scripts build`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the appname@0.1.0 build 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!     /vercel/.npm/_logs/2022-01-11T18_49_38_751Z-debug.log
Error: Command "npm run build" exited with 1

【问题讨论】:

    标签: reactjs firebase vercel


    【解决方案1】:

    我的猜测是firebase 包没有安装在服务器上(与本地环境不同),它很可能从package.json 中读取依赖项。

    要将firebase 添加到本地系统上的package.json,请运行:

    npm install firebase --save
    

    【讨论】:

    • 我已经多次这样做并验证了 package.json。我安装的软件包版本为:firebase@9.6.2。在我的本地环境中构建成功,在 Vercel 的生产服务器中失败并出现上述错误。
    猜你喜欢
    • 2021-11-16
    • 2022-01-16
    • 2023-01-31
    • 2019-11-08
    • 1970-01-01
    • 2021-09-13
    • 2019-12-16
    • 2020-09-29
    • 2017-01-29
    相关资源
    最近更新 更多