在使用ts-node执行ts代码,会报错Error: Cannot find module和 '@types/node/package.json'C:\Users\MI\AppData\Roaming\npm\node_modules\ts-node\src\index.ts:692
return new TSError(diagnosticText, diagnosticCodes);
^
TSError: ⨯ Unable to compile TypeScript:
hello.ts:2:5 - error TS2584: Cannot find name 'console'. Do you need to change your target library? Try changing the 'lib' compiler option to include 'dom'.
2 console.log('hi'+name);
~~~~~~~
解决方法:
npm install -D tslib @types/node