1. process is not defined
项目中引入了path,,想用它的resolve方法,但是报process is not defined的错误
发现是因为path方法用到了platform属性,但是在vite2中process为undefined
那也就是说,所有用到process属性的库都会有这个问题
在网上找到了答案,参考链接在最下面
export default defineConfig({
// ...
define: {
'process.env': process.env
}
})
可以在vite.config.js中加入这个定义,可以解决这个问题,我在问题栏发现有人反馈可能打包时也会有这个问题,但是我这边没有重现,要是有大佬知道更好的解决方案还请随意批评怼我,万分感谢!!!
process.env
is removed by 8ad7ecd, you can use import.meta.env
instead
https://github.com/vitejs/vite/issues/1973#issuecomment-787571499