spfx-fast-serve: PostCSS error using Fast Serve 1.20.0 on new SPFx 1.20.0 project
EDIT: Added updates in second comment
Created a new SPFx 1.20.0 React webpart using yo @microsoft/sharepoint and ran spfx-fast-serve to initialize it in the project.
Error: PostCSS plugin autoprefixer requires PostCSS 8
I assume it’s fast serve related since gulp serve works fine? The error went away when I added postcss as a dev dependency
Output and package.json below
Output
[17:05:42] Node flags detected: --max-old-space-size=8192
[17:05:42] Respawned to PID: 1524
Build target: DEBUG
[17:05:44] Using gulpfile C:\RespositoriesGit\CP\120\gulpfile.js
[17:05:44] Starting 'bundle'...
[17:05:44] Starting gulp
[17:05:44] Starting subtask 'pre-copy'...
[17:05:44] Finished subtask 'pre-copy' after 12 ms
[17:05:44] Starting subtask 'copy-static-assets'...
[17:05:44] Starting subtask 'sass'...
[17:05:45] Finished subtask 'sass' after 320 ms
[17:05:45] Starting subtask 'lint'...
[17:05:45] [lint] eslint version: 8.57.0
[17:05:45] Starting subtask 'tsc'...
[17:05:45] [tsc] typescript version: 4.7.4
[17:05:45] Finished subtask 'copy-static-assets' after 384 ms
[17:05:47] Finished subtask 'tsc' after 2.12 s
[17:05:47] Starting subtask 'save-webpack-config'...
[17:05:47] Finished subtask 'save-webpack-config' after 486 μs
[17:05:48] Finished subtask 'lint' after 3.46 s
[17:05:48] Starting subtask 'post-copy'...
[17:05:48] Finished subtask 'post-copy' after 197 μs
[17:05:48] Starting subtask 'configure-webpack'...
[17:05:48] Finished subtask 'configure-webpack' after 360 ms
[17:05:48] Starting subtask 'webpack'...
[17:05:50] Finished subtask 'webpack' after 1.37 s
[17:05:50] Finished 'bundle' after 5.53 s
[17:05:50] ==================[ Finished ]==================
[17:05:51] Project 120 version:0.0.1
[17:05:51] Build tools version:3.19.0
[17:05:51] Node version:v18.20.2
[17:05:51] Total duration:8.72 s
[17:05:52] [fast-serve] To load your scripts, use this query string: ?debug=true&noredir=true&debugManifestsFile=https://localhost:4321/temp/manifests.js
<i> [webpack-dev-server] Project is running at:
<i> [webpack-dev-server] Loopback: https://localhost:4321/, https://[::1]:4321/
<i> [webpack-dev-server] Content not from webpack is served from 'C:\RespositoriesGit\CP\120\temp' directory
<i> [webpack-dev-server] 404s will fallback to '/index.html'
Entrypoint hello-world-web-part 243 KiB (24.8 KiB) = hello-world-web-part.js 2 auxiliary assets
ERROR in ./src/webparts/helloWorld/components/HelloWorld.module.scss (./node_modules/spfx-css-modules-typescript-loader/index.js!./node_modules/spfx-fast-serve-helpers/node_modules/css-loader/dist/cjs.js??ruleSet[1].rules[5].use[2]!./node_modules/spfx-fast-serve-helpers/node_modules/clean-css-loader/lib/index.js??ruleSet[1].rules[5].use[3]!./node_modules/postcss-loader/dist/cjs.js??ruleSet[1].rules[5].use[4]!./node_modules/sass-loader/dist/cjs.js??ruleSet[1].rules[5].use[5]!./src/webparts/helloWorld/components/HelloWorld.module.scss)
Module build failed (from ./node_modules/postcss-loader/dist/cjs.js):
Error: PostCSS plugin autoprefixer requires PostCSS 8.
Migration guide for end-users:
https://github.com/postcss/postcss/wiki/PostCSS-8-for-end-users
at Processor.normalize (C:\RespositoriesGit\CP\120\node_modules\postcss\lib\processor.js:167:15)
at new Processor (C:\RespositoriesGit\CP\120\node_modules\postcss\lib\processor.js:56:25)
at postcss (C:\RespositoriesGit\CP\120\node_modules\postcss\lib\postcss.js:55:10)
at Object.loader (C:\RespositoriesGit\CP\120\node_modules\postcss-loader\dist\index.js:83:17)
webpack compiled in 1393 ms
Type-checking in progress...
No errors found.
package.json (default that comes with SPFx React webpart + fast serve)
{
"name": "120",
"version": "0.0.1",
"private": true,
"engines": {
"node": ">=18.17.1 <19.0.0"
},
"main": "lib/index.js",
"scripts": {
"build": "gulp bundle",
"clean": "gulp clean",
"test": "gulp test",
"serve": "fast-serve"
},
"dependencies": {
"tslib": "2.3.1",
"react": "17.0.1",
"react-dom": "17.0.1",
"@fluentui/react": "^8.106.4",
"@microsoft/sp-core-library": "1.20.0",
"@microsoft/sp-component-base": "1.20.0",
"@microsoft/sp-property-pane": "1.20.0",
"@microsoft/sp-webpart-base": "1.20.0",
"@microsoft/sp-lodash-subset": "1.20.0",
"@microsoft/sp-office-ui-fabric-core": "1.20.0"
},
"devDependencies": {
"@microsoft/rush-stack-compiler-4.7": "0.1.0",
"@rushstack/eslint-config": "4.0.1",
"@microsoft/eslint-plugin-spfx": "1.20.2",
"@microsoft/eslint-config-spfx": "1.20.2",
"@microsoft/sp-build-web": "1.20.2",
"@types/webpack-env": "~1.15.2",
"ajv": "^6.12.5",
"eslint": "8.57.0",
"gulp": "4.0.2",
"typescript": "4.7.4",
"@types/react": "17.0.45",
"@types/react-dom": "17.0.17",
"eslint-plugin-react-hooks": "4.3.0",
"@microsoft/sp-module-interfaces": "1.20.2",
"spfx-fast-serve-helpers": "~1.20.0"
}
}
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 19 (10 by maintainers)
I uninstalled postcss like I did with the new project and everything still works in 1.20 in my main project. I was curious if I deleted node_modules and reinstalled if it would still work and it did not. A fresh install on a new project and existing project shows the “upgrade/install postcss” error but then removing it doesn’t show the error again. I also ran
npm dedupeand everything still works. It’s not until I delete node_modules and reinstall does it break again. Now that I think about it, I have seen the PostCSS error before on previous fast serve versions. The error went away and I figured it was something I broke on my own and forgot about it. I probably haven’t deleted my node_modules folder since then which is why I haven’t seen it again.I downgraded to 1.19 and got the same error above as I got with 1.20 so it looks like it’s the same as the other ticket and not related to 1.20. I did not have this issue with 1.19 until now. Something I did with my project triggered this error and now I get it for both versions.
These are the steps I took when downgrading
Here is the output starting at npm install and my 2 files using 1.19
package.json package-lock.json
package.json
package-lock.json