test文件夹下有一个developer.test.ts文件,第一句就是import * as assert from 'assert/strict',没有显示语法错误,我也检查了node_modules/@types/node/asset/strict.d.ts这个文件是存在的,代码如下:
declare module 'assert/strict' {
import { strict } from 'node:assert';
export = strict;
}
declare module 'node:assert/strict' {
import { strict } from 'node:assert';
export = strict;
}
当我用如下命令:npm run test:developer 测试文件时,报错:Error: Cannot find package 'assert' imported from C:\Users\xiaola\btp1\ase\test\developer.test.ts
tsconfig.json文件如下:
{
"compilerOptions": {
"module": "Node16",
"outDir": "dist",
"rootDir": ".",
"target": "ES2020",
"strict": true,
"skipLibCheck": true,
"sourceMap": true,
"lib": ["ES2020"]
},
"include": [
"src/**/*.ts",
"test/**/*.ts"
],
// Most ts-node options can be specified here using their programmatic names.
"ts-node": {
"esm": true,
"compilerOptions": {
// compilerOptions specified here will override those declared below,
// but *only* in ts-node. Useful if you want ts-node and tsc to use
// different options with a single tsconfig.json.
},
}
}