最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Node.js core module fallback in vite as webpack - Stack Overflow

programmeradmin3浏览0评论

In webpack when I get the error "Uncaught TypeError: path.join is not a function" I could add the configuration

resolve: {
    fallback: { "path": require.resolve("path-browserify") }
}

to solve.

How do I do such thing in vite?

In webpack when I get the error "Uncaught TypeError: path.join is not a function" I could add the configuration

resolve: {
    fallback: { "path": require.resolve("path-browserify") }
}

to solve.

How do I do such thing in vite?

Share Improve this question asked Apr 8, 2021 at 1:32 benjaminchanmingbenjaminchanming 6281 gold badge7 silver badges21 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 9

You can use resolve.alias configuration option

export default defineConfig({
  resolve: {
    alias: {
      path: 'path-browserify',
    },
  },
})

Documentation: https://vitejs.dev/config/#resolve-alias

发布评论

评论列表(0)

  1. 暂无评论