program tip

Mac OS에서 Node.js를 최신 버전으로 업그레이드

radiobox 2020. 10. 2. 21:57
반응형

Mac OS에서 Node.js를 최신 버전으로 업그레이드


현재 Mac OS X 10.7.4에서 Node.js v0.6.16을 사용하고 있습니다. 이제 최신 Node.js v0.8.1로 업그레이드하고 싶습니다. 그러나 nodejs.org에서 최신 패키지 파일을 다운로드하여 설치 한 후 터미널에 "node -v"를 입력했을 때 시스템이 v0.8.1 대신 v0.6.16을 사용하고 있음을 발견했습니다. 내가 놓친 단계가 있습니까? 아니면 최신 버전을 설치하기 전에 이전 버전을 완전히 제거해야합니까?

BTW, nvm이 nodejs 패키지를 관리하는 데 도움이 될 수 있다는 것을 알고 있습니다.

https://github.com/creationix/nvm/

Node.js를 사용하지 않고 업그레이드 할 수있는 방법이 있습니까?

나는이 문제를 검색했지만 최신 Node.js에 대한이 질문에 대한 명확한 대답이없는 것 같습니다.


여기가 성공적으로 업그레이드 방법 v0.8.18에 대한 v0.10.20 다른 요구 사항없이 (터미널에서 다음 명령을 입력), 양조 등 같은 :

  1. sudo npm cache clean -f (강제) npm 캐시 지우기
  2. sudo npm install -g nn 설치 (시간이 걸릴 수 있음)
  3. sudo n stable 현재 안정 버전으로 업그레이드

참고 sudo비밀번호를 묻는 메시지를 표시 할 수 있습니다.

3 단계에 대한 추가 참고 사항 stablelatest, lts(장기 지원) 또는 0.10.20.

을 입력 할 때 버전 번호가 표시되지 않으면 node -v재부팅해야 할 수 있습니다.

이 지침은 여기에서도 찾을 수 있습니다 davidwalsh.name/upgrade-nodejs
에 대한 자세한 정보 n 개의 패키지는 여기에서 찾을 : npmjs.com/package/n
Node.js를 '출시 일정에 대한 자세한 정보 : github.com/nodejs/Release


Homebrew 와 함께 Node.js 를 처음 설치 한 경우 다음을 실행합니다.

brew update
brew upgrade node
npm update -g npm

또는 한 줄로 :

brew update && brew upgrade node && npm update -g npm

참고 : npm --version2.7.1 미만인 경우 update(위)를 install.


버전을 변경하는 편리한 방법은 nvm 을 사용하는 것입니다 .

brew install nvm

nvm을 사용하여 최신 버전의 Node.js를 설치하려면 :

nvm install node

패키지를 통해 설치 한 경우 nodejs.org 에서 최신 버전을 다운로드하십시오 . Node.js 설치 및 npm 업데이트를 참조하십시오 .


이것은 Mac에서 nodejs를 업그레이드하는 방법을 검색 할 때 Google의 최상위에있는 것 같기 때문에 나이에도 불구하고 앞으로 올 모든 사람에게 팁을 제공 할 것입니다.

NPM을 통한 업그레이드
위의 @Mathias에서 설명한 방법을 사용하거나 터미널을 통해 다음과 같은 간단한 방법을 선택할 수 있습니다.

sudo npm cache clean -f
sudo npm install -g n
sudo n stable

그 후 업그레이드 확인을 선택할 수 있습니다.

node -v

nodejs가 최신 버전으로 업그레이드되어야합니다. 특정 버전으로 업그레이드하려면 v0.8.19 대신

sudo n stable

사용하다

sudo n 0.8.19

편집 필요하지 않으면 sudo를 사용하지 마십시오. 코멘트에서 Steve의 코멘트를 참조하십시오


http://nodejs.org로 이동 하여 설치 프로그램을 다운로드하고 실행하십시오. 지금은 작동합니다-적어도 저에게는.


nvm을 설치 하고 여러 버전의 Node.js를 설치할 수 있습니다.

curl https://raw.github.com/creationix/nvm/master/install.sh | sh
source ~/.nvm/nvm.sh

그런 다음 다음을 실행하십시오.

nvm install 0.8.22  #(or whatever version of Node.js you want)

설치 한 버전을 확인할 수 있습니다.

nvm list

다음을 사용하여 버전간에 변경할 수 있습니다.

nvm use 0.8.22

NVM 사용의 가장 좋은 점은 서로 다른 버전을 함께 테스트 할 수 있다는 것입니다. 다른 앱에 다른 버전의 Node.js가 필요한 경우 둘 다 실행할 수 있습니다.


나는 그것을 위해 노드 버전 관리자 (n이라고 함)를 사용합니다.

npm install -g n

그때

n latest

또는

n stable

Node JS 웹 사이트로 이동하여 최신 버전을 설치하기 만하면됩니다.

권장되는 안정 버전 대신 최신 버전을 설치하십시오. 노드에서 최신 ES6 기능을 자유롭게 사용할 수 있습니다.

여기에서 찾을 수 있습니다 Node JS .

npm 을 업데이트 하려면이 명령을 사용해야합니다.

sudo npm i -g npm@latest

모든 프로젝트가 잘 작동합니다.


Mac 용 기타 옵션 :: brew update && brew install node && npm -g npm


macOS에서 homebrew 권장 방법은 실행하는 것입니다.

brew install node
npm install -g npm@latest

터미널 명령 스크린 샷


다음 명령을 사용하여 노드를 업그레이드 할 수 있습니다.

nvm install node --reinstall-packages-from=node

sadly, n doesn't worked for me. I use node version manager or nvm and it works like a charm. heres the link on how to install nvm: https://github.com/creationix/nvm#installation

  • nvm i 8.11.2 upgrade to latest LTS
  • nvm use 8.11.2 use it
  • node -v check your latest version

Go to the website nodejs.org and download the latest pkg then install. it works for me

I used brew to upgrade my node. It has installed but it located in /usr/local/Cellar/node/5.5.0 and there is a default node in /usr/local/bin/node which bothers me. I don't want to make soft link because I don't really know how brew is organized. So I download the pkg file, installed and I got this info:

Node.js was installed at

/usr/local/bin/node

npm was installed at

/usr/local/bin/npm

Make sure that /usr/local/bin is in your $PATH.

Now the upgrade is completed


You can just go to nodejs.org and download the newest package. It will update appropriately for you. NPM will be updated as well.


You can run but you can't hide... At the end you will be using NVM anyways.


I think the simplest way to use the newest version of Node.js is to get the newest Node.js pkg file in the website https://nodejs.org/en/download/current/ if you want to use different version of Node.js you can use nvm or n to manage it.


Nvm Nvm is a script-based node version manager. You can install it easily with a curl and bash one-liner as described in the documentation. It's also available on Homebrew.

Assuming you have successfully installed nvm. The following will install the latest version of node.

 nvm install node --reinstall-packages-from=node

The last option installs all global npm packages over to your new version. This way packages like mocha and node-inspector keep working.

N N is an npm-based node version manager. You can install it by installing first some version of node and then running npm install -g n.

Assuming you have successfully installed n. The following will install the latest version of node.

sudo n latest

Homebrew Homebrew is one of the two popular package managers for Mac. Assuming you have previously installed node with brew install node. You can get up-to-date with formulae and upgrade to the latest Node.js version with the following.

1 brew update
2 brew upgrade node

MacPorts MacPorts is the another package manager for Mac. The following will update the local ports tree to get access to updated versions. Then it will install the latest version of Node.js. This works even if you have previous version of the package installed.

1 sudo port selfupdate
2 sudo port install nodejs-devel

sudo npm install -g n

and then

sudo n latest for linux/mac users

For Windows please reinstall node.


These 2 methods I tried are not working:

  1. Use npm

sudo npm cache clean -f

sudo npm install -g n

sudo n stable

  1. Manual install node from official website (https://nodejs.org/en/)

After trying, node -v still shows the old version of node.


Below method works for me:

Step 1: Install nvm (for more details: https://github.com/creationix/nvm#installation)

Open terminal and type this command:

curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash

Close terminal and reopen it.

Type this command to check if nvm is installed:

command -v nvm

여기에 이미지 설명 입력

Step 2: To download, compile, and install the latest release of node, type this:

nvm install node ("node" is an alias for the latest version)

To check if node gets the latest version (v10.11.0).

여기에 이미지 설명 입력

Installing the latest node also installs the latest npm.

Check if npm gets the latest version (6.4.1).

여기에 이미지 설명 입력


for latest release: nvm install node

specific version: nvm install 6.14.4

https://github.com/creationix/nvm


Use nvm to upgrade node as per the project requirement..

install nvm through homebrew.. brew update brew install nvm mkdir ~/.nvm nano ~/.bash_profile

In your .bash_profile file (you may be using an other file, according to your shell), add the following :

export NVM_DIR=~/.nvm source $(brew --prefix nvm)/nvm.sh

source ~/.bash_profile echo $NVM_DIR


I had the same problem. This is what worked for me because I downloaded and installed node.js globally from the node.js website.

What I did was Give NVM (Node Version Manager) a try. Please do the commands in the following order in your terminal

  1. curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash

  2. command -v nvm

  3. nvm install node

  4. node -v (to confirm the update)


You can directly use curl to upgrade node to the latest version. Run the following command:

curl "https://nodejs.org/dist/latest/node-${VERSION:-$(wget -qO- https://nodejs.org/dist/latest/ | sed -nE 's|.*>node-(.*)\.pkg</a>.*|\1|p')}.pkg" > "$HOME/Downloads/node-latest.pkg" && sudo installer -store -pkg "$HOME/Downloads/node-latest.pkg" -target "/"

Reference: https://nodejs.org/en/download/package-manager/#macos


Easy nad Safe Steps

Step 1: Install NVM

brew install nvm

Step 2: Create a directory for NVM

mkdir ~/.nvm/

Step 3: Configure your environmental variables

nano ~/.bash_profile

PASTE BELOW CODE

export NVM_DIR=~/.nvm
source $(brew --prefix nvm)/nvm.sh

source ~/.bash_profile

Step 4: Double check your work

nvm ls

Step 5: Install Node

nvm install 9.x.x

Step6: Upgrade

nvm ls-remote

   v10.16.2   (LTS: Dubnium)
   v10.16.3   (Latest LTS: Dubnium) ..........

nvm install v10.16.3

문제 해결

Error Example #1
rm -rf /usr/local/lib/node_modules
brew uninstall node
brew install node --without-npm
echo prefix=~/.npm-packages >> ~/.npmrc
curl -L https://www.npmjs.com/install.sh | sh

https://www.chrisjmendez.com/2018/02/07/install/


한 줄의 코드로 20 초 만에 업데이트 할 수있었습니다.

sudo n latest

다른 명령이 작동하지 않았지만이 명령은 작동했습니다. 누군가에게 도움이되기를 바랍니다.

참고 URL : https://stackoverflow.com/questions/11284634/upgrade-node-js-to-the-latest-version-on-mac-os

반응형