【问题标题】:Error affecting vercel deployment but not a local build影响 vercel 部署但不影响本地构建的错误
【发布时间】:2022-06-11 04:12:54
【问题描述】:

我在 Vercel 或 Heroku 上编译时不断收到此错误,但在我的 PC 上没有。

Module not found: Error: You attempted to import /vercel/path0/node_modules/console-browserify/index.js which falls outside of the project src/ directory. Relative imports outside of src/ are not supported.

这是我在 Vercel 上运行 npm run build 时遇到的错误,它不会在本地构建中发生。

我尝试更改 webpack 版本(它只是给出了不同的错误)。 我不知道在哪里使用控制台浏览器(除了反应本身)。

【问题讨论】:

    标签: javascript reactjs browserify


    【解决方案1】:

    我在 Netlify 上部署时遇到了同样的问题。我正在使用https://github.com/Richienb/node-polyfill-webpack-plugin

    我所要做的就是排除控制台浏览

    const NodePolyfillPlugin = require("node-polyfill-webpack-plugin")
    
    module.exports = {
        // Other rules...
        plugins: [
            new NodePolyfillPlugin({
                excludeAliases: ["console"]
            })
        ]
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-04-11
      • 2020-04-05
      • 1970-01-01
      • 1970-01-01
      • 2020-11-27
      • 2022-08-13
      相关资源
      最近更新 更多