Closed Heromyth closed 1 year ago
You need to configure your project to be ESM like this:
It seems to lead to more errors:
Failed to load PostCSS config (searchPath: /home/vue/vue-admin-lite): [ReferenceError] module is not defined in ES module scope
This file is being treated as an ES module because it has a '.js' file extension and '/home/vue/vue-admin-lite/package.json' contains "type": "module". To treat it as a CommonJS script, rename it to use the '.cjs' file extension.
ReferenceError: module is not defined in ES module scope
This file is being treated as an ES module because it has a '.js' file extension and '/home/vue/vue-admin-lite/package.json' contains "type": "module". To treat it as a CommonJS script, rename it to use the '.cjs' file extension.
at file:///home/vue/vue-admin-lite/postcss.config.js:1:1
at ModuleJob.run (node:internal/modules/esm/module_job:193:25)
at async Promise.all (index 0)
at async ESMLoader.import (node:internal/modules/esm/loader:533:24)
......
You need to configure your project to be ESM like this:
Either rename your postcss.config.js
to postcss.config.cjs
as said in the error, or change module.exports = {your: config}
to export default {your: config}
.
FYI: if you are not familiar with ESM, here's a good read. Official Vite templates use ESM by default, so you need to learn it eventually.
Thanks. It works now. I have uninstalled the postcss.
The Vit config
The error message:
The version of Node is v16.17.0