0

처음에 몇 시간 씩 인터넷 검색 결과를 보지 못했습니다. 뭔가를 간과하면 죄송합니다.Typescript 프로젝트 설정 (처음)

빠른 버전 타이프 라이터로 는 어떻게 outDir-node_modules를 이동하거나 내가 잘못된 방향으로 일들에 대해 하겠어?

내가 타이프를 시작하려고하고 프로젝트를 구성하고있어 긴 버전은 가장 어려운 부분이 될 것으로 보인다.

Project 
+-/bin 
| +/server 
|  +-server.js 
+-/src 
    +/server 
    +-server.ts 
    +-package.json 
    +-/node_modules 
     +-[...] 
    +-/typings 
     +-[...] 

: 여기

{ 
    "compilerOptions": { 
     "allowJs": true, 
     "emitDecoratorMetadata": true, 
     "experimentalDecorators": true, 
     "module": "commonjs", 
     "moduleResolution": "node", 
     "noEmitOnError": true, 
     "noImplicitAny": false, 
     "outDir": "../../bin", 
     "sourceMap": true, 
     "suppressImplicitAnyIndexErrors": true, 
     "target": "ES2015", 
     "typeRoots": [ 
     "../../node_modules/@types/" 
     ] 
    }, 
    "exclude": [ 
     "bin/*", 
     "node_modules/*", 
     "public/*", 
     "**/*-aot.ts" 
    ] 
} 

디렉토리 구조입니다 : 내 목표는 여기에

bin/server에있을 src/server 내 소스 코드와 내 출력을 참조에 대한 내 tsconfig.json입니다 ~/Project에서 컴파일하려면 을 사용하고, 붐에는 bin/server/server.js이 있습니다.

{ 
    "version": "0.2.0", 
    "configurations": [{ 
     "outFiles": [ "${workspaceRoot}/bin/server/**/*.js" ], 
     "cwd": "${workspaceRoot}/bin/server", 
     "name": "Launch", 
     "type": "node", 
     "request": "launch", 
     "program": "${workspaceRoot}/src/server/server.ts", 
     "sourceMaps": true, 
     "env": { 
      "NODE_ENV": "development", 
      "SERVER": "http://localhost:8080" 
     } 
    }] 
} 

내가 점점 오전 오류가 Error: Cannot find module 'express'이며, 모듈 그래서 나는 내가으로 bin/servernode_modules를 이동해야 같은데요 src/server/node_modules/express에 설치됩니다

여기 launch.json, 내가 코드 대 사용하고 실행하려면 잘? 그건 맞지 않아.

초판 글쓰기 초보자 (오늘 시작) 내 긴 게시물을 읽는 데 시간을내어 주셔서 감사합니다.

추신 : 모든 것이 최신 버전이라고 가정합니다.

답변

1

답변 됨 found!

tsconfig.json을 src/server/으로 옮기고 프로젝트 루트에서 tsc -p src/server을 실행했습니다. 참조

업데이트 tsconfig.json : 틱을 클릭하여 문제에 대한 해결책으로

{ 
    "compilerOptions": { 
     "allowJs": true, 
     "emitDecoratorMetadata": true, 
     "experimentalDecorators": true, 
     "module": "commonjs", 
     "moduleResolution": "node", 
     "noEmitOnError": true, 
     "noImplicitAny": false, 
     "outDir": "../../bin", 
     "sourceMap": true, 
     "suppressImplicitAnyIndexErrors": true, 
     "target": "ES2015", 
     "typeRoots": ["node_modules/@types/"] 
    }, 
    "exclude": [ 
     "bin/*", 
     "node_modules/*", 
     "public/*", 
     "**/*-aot.ts" 
    ] 
} 
+0

켭니다. – androbin