에러 내용
node:internal/modules/cjs/loader:933
const err = new Error(message);
^
Error: Cannot find module 'semver'
Require stack:
- /usr/share/nodejs/npm/lib/utils/unsupported.js
- /usr/share/nodejs/npm/lib/cli.js
- /usr/share/nodejs/npm/bin/npm-cli.js
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
at Function.Module._load (node:internal/modules/cjs/loader:778:27)
at Module.require (node:internal/modules/cjs/loader:1005:19)
at require (node:internal/modules/cjs/helpers:102:18)
at Object.<anonymous> (/usr/share/nodejs/npm/lib/utils/unsupported.js:2:16)
at Module._compile (node:internal/modules/cjs/loader:1105:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Module.require (node:internal/modules/cjs/loader:1005:19) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'/usr/share/nodejs/npm/lib/utils/unsupported.js',
'/usr/share/nodejs/npm/lib/cli.js',
'/usr/share/nodejs/npm/bin/npm-cli.js'
]
}
npm 관련 명령 시 "Error: Cannot find module 'semver'"라는 오류가 출력됩니다.
에러 원인
npm 및 node 버전 오류입니다.
해결 방법
1. 기존 node 삭제
sudo rm -rf /usr/local/bin/npm /usr/local/share/man/man1/node* /usr/local/lib/dtrace/node.d ~/.npm ~/.node-gyp /opt/local/bin/node /opt/local/include/node /opt/local/lib/node_modules
sudo rm -rf /usr/local/lib/node* ; sudo rm -rf /usr/local/include/node* ; sudo rm -rf /usr/local/bin/node*
sudo apt-get purge nodejs npm
2. 새로운 node 및 npm 설치
sudo apt install -y nodejs npm
sudo npm cache clean -f
3. node 및 npm 업데이트
sudo npm install npm
sudo npm install -g n
sudo n stable
4. 버전 확인
node --version
npm --version
만일, 계속 구버전이 출력된다면
참고 자료
'개발 > 에러해결' 카테고리의 다른 글
export 'Switch' (imported as 'Switch') was not found in 'react-router-dom' (0) | 2022.10.22 |
---|---|
docker-compose 시 exited with code 0 또는 무한 재시작 (0) | 2022.10.22 |
n stable 후 node old version (0) | 2022.10.22 |
docker-compose up 명령 시 ~service 'app' must be a mapping not a string. (0) | 2022.10.22 |
Dockerfile build 시 timezone 해결법 (0) | 2022.10.21 |
댓글