自从更新到 Angular 13 以来,我从 @angular/cdk 导入的 Cypress 测试(主要是在 Angular 材料上使用测试工具)无法编译,并出现以下错误:
Error: Webpack Compilation Error
./node_modules/@angular/cdk/fesm2015/platform.mjs
Module not found: Error: Can't resolve '@angular/common' in 'C:\dev\workspace\exp\cypress-test\node_modules\@angular\cdk\fesm2015'
resolve '@angular/common' in 'C:\dev\workspace\exp\cypress-test\node_modules\@angular\cdk\fesm2015'
Parsed request is a module
using description file: C:\dev\workspace\exp\cypress-test\node_modules\@angular\cdk\package.json (relative path: ./fesm2015)
Field 'browser' doesn't contain a valid alias configuration
resolve as module
C:\dev\workspace\exp\cypress-test\node_modules\@angular\cdk\fesm2015\node_modules doesn't exist or is not a directory
C:\dev\workspace\exp\cypress-test\node_modules\@angular\node_modules doesn't exist or is not a directory
C:\dev\workspace\exp\cypress-test\node_modules\node_modules doesn't exist or is not a directory
C:\dev\workspace\exp\node_modules doesn't exist or is …Run Code Online (Sandbox Code Playgroud) 使用 Angular 13 以及ng-packagr当我们发布带有库的 SASS mixin 时,我们需要将该库添加到导出中package.json,并assets在ng-package.json.
这些是说明。
\nhttps://github.com/ng-packagr/ng-packagr/blob/main/docs/copy-assets.md
\n本期也对此进行了解释:\n SCSS @use 语句中的波浪号 ~ 自 Angular 13 起不再解析为 node_modules
\n所以我已经为这个项目做到了这一点:\n https://github.com/fireflysemantics/big-packaged-component-example
\n这是ng-package.json配置:
{\n "$schema": "../../node_modules/ng-packagr/ng-package.schema.json",\n "dest": "../../dist/big",\n "assets": [\n "./src/CHANGELOG.md",\n "./src/lib/**/*.theme.scss"\n ],\n "lib": {\n "entryFile": "src/public-api.ts"\n }\n}\nRun Code Online (Sandbox Code Playgroud)\n这是package.json配置:
\n \n{\n "name": "@fireflysemantics/big-packaged-component-example",\n "version": "0.0.7",\n "exports": {\n ".": {\n "sass": "./src/lib/big.component.theme.scss"\n }\n },\n "peerDependencies": {\n "@angular/common": "^13.3.0",\n "@angular/core": "^13.3.0"\n },\n "dependencies": …Run Code Online (Sandbox Code Playgroud) 之后NPM安装,当我尝试“纳克构建”出现以下错误:
ERROR in node_modules/@types/node/globals.d.ts(713,19): error TS2304: Cannot find name 'bigint'.
node_modules/@types/node/ts3.6/base.d.ts(13,21): error TS2727: Cannot find lib definition for 'esnext.bigint'. Did you mean 'esnext.intl'?
node_modules/@types/node/util.d.ts(119,56): error TS2304: Cannot find name 'BigInt64Array'.
node_modules/@types/node/util.d.ts(120,57): error TS2304: Cannot find name 'BigUint64Array'.
Run Code Online (Sandbox Code Playgroud)