在 GitHub Actions 中,我正在测试该actions-ecosystem/action-create-issue操作。
此操作会创建一个自动 github 问题。
但操作崩溃了,我不断收到此错误:
触发此错误(并可用于重现该错误)的工作流程 yaml 文件是以下代码:
name: Deploy to foo
on:
push:
branches: [develop]
jobs:
deploy-to-staging:
name: Deploy to Staging
permissions:
contents: 'read'
id-token: 'write'
runs-on: ubuntu-latest
steps:
- name: Create deploy issue
uses: actions-ecosystem/action-create-issue@v1
with:
github_token: ${{ secrets.github_token }}
title: Hello World
body: |
## Deployed to Staging Server
- [ ] Task-1
- [ ] Task-2
labels: |
deploy
staging
Run Code Online (Sandbox Code Playgroud) 我尝试将 nanoid 导入 NestJS 并收到此错误:
错误 [ERR_REQUIRE_ESM]:ES 模块的 require() ....
... 而是将 ... 中的 index.js 的 require 更改为所有 CommonJS 模块中都可用的动态 import() 。
导入代码是:
import { Injectable } from '@nestjs/common';
import { nanoid } from 'nanoid'; //wont import, gives error
import { User } from './data-objects/user.object';
Run Code Online (Sandbox Code Playgroud)
我还尝试了导入语句的变体:
// I tried this alternative
import * as nanoid from 'nanoid';
// Also tried this
const nanoid = require ( 'nanoid' );
Run Code Online (Sandbox Code Playgroud)
什么都没起作用。
为什么会发生此错误以及我应该如何在 NestJS 中安装 nanoid ?