解决 Syntax Error: Error: PostCSS received undefined instead of CSS string

解决方法

卸载当前版本的node-sass和sass-loader,因为版本和当前的不兼容,安装对应版本的包即可。

#卸载node-sas和sass-loader

npm uninstall node-sass
npm uninstall sass-loader

安装其他版本

#安装node-sas和sass-loader

npm install node-sass@4.14.1
npm install sass-loader@8.0.0

如果npm安装不成功的话可以试一下cnpm

#安装淘宝镜像
npm install -g cnpm --registry=https://registry.npm.taobao.org
#检查是否安装成功
cnpm -v

解决后可以尝试npm run serve

npm run server

node与node-sass对照版本
链接: https://www.npmjs.com/package/node-sass.

NodeJSSupported node-sass versionNode Module
Node 177.0+102
Node 166.0+93
Node 155.0+, <7.088
Node 144.14+83
Node 134.13+, <5.079
Node 124.12+72
Node 114.10+, <5.067
Node 104.9+, <6.064
Node 84.5.3+, <5.057
Node <8<5.0<57
GitHub 加速计划 / no / node-sass
3
0
下载
:rainbow: Node.js bindings to libsass
最近提交(Master分支:3 个月前 )
6081731a Bumps [actions/setup-node](https://github.com/actions/setup-node) from 3 to 4. - [Release notes](https://github.com/actions/setup-node/releases) - [Commits](https://github.com/actions/setup-node/compare/v3...v4) --- updated-dependencies: - dependency-name: actions/setup-node dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com> 10 个月前
62c0f46c Bumps [actions/checkout](https://github.com/actions/checkout) from 3 to 4. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/checkout/compare/v3...v4) --- updated-dependencies: - dependency-name: actions/checkout dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com> 10 个月前
Logo

旨在为数千万中国开发者提供一个无缝且高效的云端环境,以支持学习、使用和贡献开源项目。

更多推荐