I encountered an issue when trying to run my simple TypeScript project. I am receiving the following error: 'Error while transforming Could not resolve import "child_process".' You can see the error in this screenshot. This error occurs in my tsconfig.json file.
{
"compilerOptions": {
"target": "es2017",
"module": "es2022",
"moduleResolution": "Node16",
"lib": ["esnext.array", "esnext", "es2017", "dom", "WebWorker"],
"strict": true,
"noUnusedLocals": true,
"esModuleInterop": true,
"noUnusedParameters": true,
"noImplicitReturns": false,
"noFallthroughCasesInSwitch": true,
"forceConsistentCasingInFileNames": true,
"noImplicitAny": false,
"noImplicitThis": true,
"outDir": "./dist/",
"skipLibCheck": true,
"experimentalDecorators": true,
"typeRoots": [
"node_modules/@types"
],
},
"include": ["src/**/*"]
}
The issue is also present in test.ts:
import { visualDiff } from '@web/test-runner-visual-regression';
import { setViewport } from '@web/test-runner-commands';
import * as child1 from 'child_process';
// startup code, runs before the tests run per browser
before(async function () {
var foo: child1.ChildProcess = child1.exec(stubService.executable);
console.log(typeof foo.on);
});