npm-workspace 구성하기 #7
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
npm 설치
.npmrc 설정하기
루트에 있는node_modulespackage에 의존할 수 있는 환경을 만든다. 이로 인해 하위 디렉토리에 불필요하게node_modulespackage를 생성하지 않게 할 수 있다. 환경 변수로 설정하는 방식도 있지만 아래와 같은 방식으로 관리 할 수 있게 명령어를 작성하면 된다.(참고로 node_modules의 의존성을 완전히 분리한 것이 아니다.)하위 디렉토리 설정
pnpm과 npm
package.lock
을 통해서 workspace에 설정한 디렉토리들을 루트에 의존하면서 관리하는 역할이다. 즉, pnp를 사용해서 node_modules에서 벗어날 수 있는 것이다. 현재 지금으론 npm을 통한 workspace를 구현하는 것에 초점이 맞추었기 때문에 pnp를 따로 다뤄보진 않을 것이다.TypeScript 설치하기
"include": ["trends/**/*"]
를 추가해주면 오류가 발생하지 않고 정상적으로 동작할 것이다.tsc
명령을 실행하면 다음과 같다.-g
의 설정이 잘 못되 었는 것이다. 보통은 위에 발생한 에러는--save -dev
를 통해서devDependencies
에 설치가 되면tsc
명령을 사용할 수 없어서 발생한다. 그렇다면 왜-g
로 설치한 나에겐 이러한 오류가 발생할까? 현재 추론으론 .npmrc가 로컬 사용자 정보에서 2개가 존재한다. 사용자 디렉토리에 하나.npm-global
에 하나 지난번 설정으로 문제가 발생한 것으로 보여진다. 둘 중 하나를 제거 해야만 정상적으로 동작할 것이다. 하지만 이부분에 시간을 쏟아내기 어려움이 있어서 대체할 명령어는 다음과 같다.Summary
-g
의 원인을 다시 잘 파악을 해보기를 바라면서 이번 이슈는 마무리 지어 보려고 한다.