728x90
반응형
로컬에서 타입스크립트 테스트를 위해 설정을 하는 와중에 console을 찾을 수 없다는 에러를 발견 해당 에러는 기본적인 @types/node가 설치되지 않아서 발생한 에러
[nodemon] starting `ts-node index.ts`
/Users/ruden/Desktop/portfolio/2022/learn-types/node_modules/ts-node/src/index.ts:750
return new TSError(diagnosticText, diagnosticCodes);
^
TSError: ⨯ Unable to compile TypeScript:
index.ts:1:1 - error TS2584: Cannot find name 'console'. Do you need to change your target library? Try changing the 'lib' compiler option to include 'dom'.
1 console.log("hello!");
~~~~~~~
at createTSError (/Users/ruden/Desktop/portfolio/2022/learn-types/node_modules/ts-node/src/index.ts:750:12)
at reportTSError (/Users/ruden/Desktop/portfolio/2022/learn-types/node_modules/ts-node/src/index.ts:754:19)
at getOutput (/Users/ruden/Desktop/portfolio/2022/learn-types/node_modules/ts-node/src/index.ts:941:36)
at Object.compile (/Users/ruden/Desktop/portfolio/2022/learn-types/node_modules/ts-node/src/index.ts:1243:30)
at Module.m._compile (/Users/ruden/Desktop/portfolio/2022/learn-types/node_modules/ts-node/src/index.ts:1370:30)
at Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
at Object.require.extensions.<computed> [as .ts] (/Users/ruden/Desktop/portfolio/2022/learn-types/node_modules/ts-node/src/index.ts:1374:12)
at Module.load (internal/modules/cjs/loader.js:863:32)
at Function.Module._load (internal/modules/cjs/loader.js:708:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:60:12) {
diagnosticText: "\u001b[96mindex.ts\u001b[0m:\u001b[93m1\u001b[0m:\u001b[93m1\u001b[0m - \u001b[91merror\u001b[0m\u001b[90m TS2584: \u001b[0mCannot find name 'console'. Do you need to change your target library? Try changing the 'lib' compiler option to include 'dom'.\n" +
'\n' +
'\u001b[7m1\u001b[0m console.log("hello!");\n' +
'\u001b[7m \u001b[0m \u001b[91m~~~~~~~\u001b[0m\n',
diagnosticCodes: [ 2584 ]
}
[nodemon] app crashed - waiting for file changes before starting...[nodemon] starting `ts-node index.ts`
/Users/ruden/Desktop/portfolio/2022/learn-types/node_modules/ts-node/src/index.ts:750
return new TSError(diagnosticText, diagnosticCodes);
^
TSError: ⨯ Unable to compile TypeScript:
index.ts:1:1 - error TS2584: Cannot find name 'console'. Do you need to change your target library? Try changing the 'lib' compiler option to include 'dom'.
1 console.log("hello!");
~~~~~~~
at createTSError (/Users/ruden/Desktop/portfolio/2022/learn-types/node_modules/ts-node/src/index.ts:750:12)
at reportTSError (/Users/ruden/Desktop/portfolio/2022/learn-types/node_modules/ts-node/src/index.ts:754:19)
at getOutput (/Users/ruden/Desktop/portfolio/2022/learn-types/node_modules/ts-node/src/index.ts:941:36)
at Object.compile (/Users/ruden/Desktop/portfolio/2022/learn-types/node_modules/ts-node/src/index.ts:1243:30)
at Module.m._compile (/Users/ruden/Desktop/portfolio/2022/learn-types/node_modules/ts-node/src/index.ts:1370:30)
at Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
at Object.require.extensions.<computed> [as .ts] (/Users/ruden/Desktop/portfolio/2022/learn-types/node_modules/ts-node/src/index.ts:1374:12)
at Module.load (internal/modules/cjs/loader.js:863:32)
at Function.Module._load (internal/modules/cjs/loader.js:708:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:60:12) {
diagnosticText: "\u001b[96mindex.ts\u001b[0m:\u001b[93m1\u001b[0m:\u001b[93m1\u001b[0m - \u001b[91merror\u001b[0m\u001b[90m TS2584: \u001b[0mCannot find name 'console'. Do you need to change your target library? Try changing the 'lib' compiler option to include 'dom'.\n" +
'\n' +
'\u001b[7m1\u001b[0m console.log("hello!");\n' +
'\u001b[7m \u001b[0m \u001b[91m~~~~~~~\u001b[0m\n',
diagnosticCodes: [ 2584 ]
}
[nodemon] app crashed - waiting for file changes before starting...
@types/node를 설치 후 로컬에서 테스트하면 정상적으로 잘 동작하는 것을 확인할 수 있다.
yarn add --dev @types/node
[nodemon] 2.0.15
[nodemon] to restart at any time, enter `rs`
[nodemon] watching path(s): *.ts
[nodemon] watching extensions: ts,json
[nodemon] starting `ts-node index.ts`
hello!
[nodemon] clean exit - waiting for changes before restart
728x90
반응형
그리드형
'개발 > 트러블슈팅' 카테고리의 다른 글
git 대소문자 파일명 폴더명 오류 (Changing capitalization of filenames in Git) (0) | 2022.03.27 |
---|---|
[Jest] Scss "Syntax Error: Invalid or unexpected token" 에러 해결방법 (0) | 2022.02.19 |
vscode eslint export a CLIEngine 에러 해결방법 (0) | 2022.02.19 |
SSH 로그인 접속 시 퍼미션 문제 (UNPROTECTED PRIVATE KEY FILE) (0) | 2021.12.15 |
타입스크립트(Typescript)에서 JSON import하는 방법 (1) | 2021.05.26 |
이 포스팅은 쿠팡파트너스 활동의 일환으로, 이에 따른 일정액의 수수료를 제공받습니다.