Skip to content

Conversation

4BFC
Copy link
Member

@4BFC 4BFC commented Sep 19, 2024

🐞Error : 로컬 .npmrc 를 설정

현재 npm을 전역에서 관리할 수 있도록 설정을 했었다. 이에 조금 더 욕심을 내서 프로젝트 내에서만 동작할 수 있는 npm관리 설정을 하고 싶어서 프로젝트에 .npmrc를 설치 했다. 이후 npm config get prefix를 내가 원하는 위치(local_node_modules)로 설정했으나 전역 path와 충돌하는 일이 발생했다.

  npm error config prefix cannot be changed from project config: D:\<myworkspace>\0_Programming-content\TrendGarage\.npmrc.
  D:\<myworkspace>\0_Programming-content\TrendGarage\local_node_modules

< 이 경로(~TrendGarage\local_node_modules) 문제 이전에는 해당 경로(C:\Users\<userNmae>\.local_node_modules)로 변경 했으나 동일한 에러가 발생 했다. >

물론 registry부분은 따로 설정하지 않았다. 기본적으로 설정될 것이라 예상을 했기 때문이다. 원인을 계속해서 분석하는 중에 문뜩 이런 생각이 들었다. 현재 관리되고 있는 .npm-global은 새로운 디렉토리기에 내가 원하는 환경을 다시 세팅해야한다는 번거로움으로 로컬에 생성하려고 하는 것 아닌가?

전역 npmrc prefix 경로 설정 변경

결국에는 초기에 사용하고 있던 경로(C:\Users\<userName>\AppData\Roaming\npm)로 변경을 했다. 과거 사용했던 전역 디렉토리에는 typescript가 존재하지 않아 프로젝트 루트 package에 typescript를 설치했다. 다시 한번 상기하지만 전역 패키지의 실행 파일 경로가 시스템 환경 변수에 추가되어 있어야 npx 없이 명령을 사용할 수 있다. 따라서 로컬 패키지는 npm scripts나 npx로 실행해야 한다.

@4BFC 4BFC added 🐞bug 🐞bug 🧰npm 🧰npm 🌐workspace 🌐workspace labels Sep 19, 2024
@4BFC 4BFC added this to the 🛠Config milestone Sep 19, 2024
@4BFC 4BFC self-assigned this Sep 19, 2024
@4BFC 4BFC linked an issue Sep 19, 2024 that may be closed by this pull request
2 tasks
@4BFC 4BFC merged commit 9b2c23e into npmworksapce-r Sep 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐞bug 🐞bug 🧰npm 🧰npm 🌐workspace 🌐workspace
Projects
None yet
Development

Successfully merging this pull request may close these issues.

전역 .npmrc prefix 경로 설정을 변경한다.
1 participant