小编Kas*_*rot的帖子

错误:尝试运行节点容器时 ES 模块的 require()

我正在尝试使用 Github Action 构建我的角度应用程序。我在操作中遇到了一些由所使用的容器引起的错误。现在,我构建一个基本的本地容器,尝试运行 linter 作为第一步。

Dockerfile

FROM node:18.18

COPY ./ ./

RUN yarn install
RUN yarn lint
Run Code Online (Sandbox Code Playgroud)

如果我尝试构建容器,则会遇到以下错误:

Node.js v18.18.0"
info This module is OPTIONAL, you can safely ignore this error
error /node_modules/@parcel/watcher: Command failed.
Exit code: 1
Command: node-gyp-build
Arguments:
Directory: /node_modules/@parcel/watcher
Output:
/node_modules/wide-align/align.js:2
var stringWidth = require('string-width')
                  ^

Error [ERR_REQUIRE_ESM]: require() of ES Module /node_modules/string-width/index.js from /node_modules/wide-align/align.js not supported.
Instead change the require of index.js in /node_modules/wide-align/align.js to a dynamic import() which is available in all CommonJS …
Run Code Online (Sandbox Code Playgroud)

node.js docker

3
推荐指数
1
解决办法
3580
查看次数

如何使用 ControlValueAccessor 在 Angular 8 中默认选择 mat-button-toggle

我正在尝试使用 Angulars ControlValueAccessor 创建自定义元素。目标是具有三种状态的开关:真、假和空。默认情况下应选择 Null,我尝试了其他帖子中的一些解决方案,但它们不起作用。
我尝试在 mat-button-toggle-group 中添加“value=null”,并在 null mat-button-toggle 本身中添加“checked”属性。

HTML:

<div class="nullableBoolWrapper" fxLayout="row">
<mat-label class="centred-vertically">{{ label }}</mat-label>
<mat-button-toggle-group class="selection-button"
[disabled]="isDisabled"
[(ngModel)]="selectedValue"
(change)="changed($event)">
    <mat-button-toggle ngDefaultControl value=true>{{ descriptionList[0].description }}</mat-button-toggle>
    <mat-button-toggle ngDefaultControl value=false>{{ descriptionList[1].description }}</mat-button-toggle>
    <mat-button-toggle ngDefaultControl value=null [disabled]="!selectableNull">{{ descriptionList[2].description }}</mat-button-toggle>
</mat-button-toggle-group>
Run Code Online (Sandbox Code Playgroud)

TS:

import { Description } from './../core/models/description';
import { Component, ViewEncapsulation, forwardRef, Input, OnInit } from '@angular/core';
import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms';

export const NULLABLE_BOOL_VALUE_ACCESSOR: any = {
  provide: NG_VALUE_ACCESSOR,
  useExisting: forwardRef(() => NullableBoolComponent),
  multi: true
}; …
Run Code Online (Sandbox Code Playgroud)

angular-material angular controlvalueaccessor angular8

1
推荐指数
1
解决办法
7515
查看次数