《Vite 报错》ReferenceError: module is not defined in ES module scope 07-02 1160阅读 ReferenceError: module is not defined in ES module scope 解决方案 postcss.config.js 要改为 postcss.config.cjs,也就是 .cjs 后缀。 原因解析 下图提示,packages.json 中的属性 type 设置为 module。所有 *.js 文件现在都被解释为 ESM;但 Vite 有说明, postcss 配置文件 暂不支持 ESM 语法,所以冲突了;改为 .cjs 后缀,继续以 CommonJS 方式加载此文件即可;想进一步了解 Vite 对 CommonJS 的 说明在此; VPS购买请点击我 文章版权声明:除非注明,否则均为主机测评原创文章,转载或复制请以超链接形式并注明出处。