Ubuntu Desktop 22.04.2 LTS
우분투에서 'npx create-react-app hello-react' 을 통해 react 프로젝트 생성시 react-scripts: 0.9.5 로 설치 되는 현상.
node를 삭제 후 다시 설치하면 react-scripts: 5.0.1 과 같이 정상적으로 설치됨.
가급적 콘솔을 통한 직접 설치 권장.
- 터미널 실행
- root 권한 획득 후 3번 명령어 실행(sudo su)
- npm ls -gp --depth=0 | awk -F/ '/node_modules/ && !/\/npm$/ {print $NF}' | xargs npm -g rm
패키지 삭제 메시지 확인 후 node 설치 진행.
출처 : StackOverFlow - Command to remove all npm modules globally
curl -fsSL https://deb.nodesource.com/setup_19.x | sudo -E bash - &&\
sudo apt-get install -y nodejs
node 삭제후 계속해서 위 명령어 전체를 복사하여 붙여넣기 후 실행.
아래 출처 사이트에서 최신버전 확인 후 설치.
출처 : Github - nodesource
// react-scripts 가 0.9.5로 설치된 package.json
{
"name": "hello-react1",
"version": "0.1.0",
"private": true,
"dependencies": {
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-scripts": "0.9.5"
},
"devDependencies": {},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"
}
}
//node 재설치 후 package.json
{
"name": "hello-react2",
"version": "0.1.0",
"private": true,
"dependencies": {
"@testing-library/jest-dom": "^5.16.5",
"@testing-library/react": "^13.4.0",
"@testing-library/user-event": "^13.5.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-scripts": "5.0.1",
"web-vitals": "^2.1.4"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
]
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
}