analogjs / analog

The fullstack meta-framework for Angular. Powered by Vite and Nitro
https://analogjs.org
MIT License
2.5k stars 240 forks source link

Error create new app with Tailwind - [Failed to load PostCSS config] #941

Closed TheNomo3000 closed 5 months ago

TheNomo3000 commented 6 months ago

Please provide the environment you discovered this bug in.

Node 18.19.0

Which area/package is the issue in?

create-analog

Description

Give error if try runnpm run dev for first time, after created new app with comand npm init analog (tested with angular17 or blog options) with Tailwind enabled and after install packages

Please provide the exception or error you saw

node:internal/process/promises:288
            triggerUncaughtException(err, true /* fromPromise */);
            ^

[Failed to load PostCSS config: Failed to load PostCSS config (searchPath: /Users/myUser/Code/example-blog): [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 '/Users/myUser/Code/example-blog/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 '/Users/myUser/Code/example-blog/package.json' contains "type": "module". To treat it as a CommonJS script, rename it to use the '.cjs' file extension.
    at file:///Users/myUser/Code/example-blog/postcss.config.js:2:1
    at ModuleJob.run (node:internal/modules/esm/module_job:195:25)
    at async ModuleLoader.import (node:internal/modules/esm/loader:336:24)
    at async importDefault (file:///Users/myUser/Code/example-blog/node_modules/vite/dist/node/chunks/dep-jvB8WLp9.js:29095:18)
    at async Object.search (file:///Users/myUser/Code/example-blog/node_modules/vite/dist/node/chunks/dep-jvB8WLp9.js:21351:42)]

Node.js v18.19.0

Other information

For correctly run, i need change the extensions files postcss.config.js and tailwind.config.js to .cjs

I would be willing to submit a PR to fix this issue

brandonroberts commented 6 months ago

Thanks @TheNomo3000. The filenames need updating here https://github.com/analogjs/analog/blob/beta/packages/create-analog/index.js#L334-L346