Angular 14升级至15后Storybook报Cannot read 'match'错误
Angular 14升级至15后Storybook构建报错:Cannot read properties of undefined (reading 'match')
我正尝试将Angular从14版本升级到15版本,升级完成后在Storybook中出现如下错误:
Cannot read properties of undefined (reading 'match')
该错误指向Webpack构建中的以下代码块:
function extractCommentsWithHash(input) { // Error references this line: return input.match(_commentWithHashRe) || []; } // Called from here: shimCssText(cssText, selector, hostSelector = '') { const commentsWithHash = extractCommentsWithHash(cssText); //.... }
这段代码上方有关于CSS深度组合器弃用的注释,因此我推测问题源于Angular安装包缺失或配置不当。
为修复该问题,我已在.storybook/main.js中添加了自定义Webpack配置:
module.exports = { webpackFinal: async (config, { configType }) => { config.module.rules.push({ test: /\.scss$/i, use: ['sass-loader'], }); return config; } }
以下是项目相关依赖信息:
{ "devDependencies": { "css-loader": "^6.8.1", "sass-loader": "^10.4.1", "style-loader": "^3.3.3", "sass": "^1.66.1", }, "peerDependencies": { "@angular/animations": ">=15.2.9", "@angular/cdk": ">=15.2.9", "@angular/cli": ">=15.2.9", "@angular/common": ">=15.2.9", "@angular/compiler": ">=15.2.9", "@angular/core": ">=15.2.9", "@angular/flex-layout": ">=15.0.0-beta.40", "@angular/forms": ">=15.2.9", "@angular/material": ">=15.2.9", "@angular/material-moment-adapter": ">=15.2.9", "@angular/platform-browser": ">=15.2.9", "@angular/platform-browser-dynamic": ">=15.2.9", "@angular/router": ">=15.2.9", "rxjs": "^7.4.0", "zone.js": "~0.11.4" } }
内容的提问来源于stack exchange,提问作者Get Off My Lawn
相关产品推荐
相关产品推荐

