Как обновить npm mac os

4 ways to update to the latest Node.js version on a Mac

Development is picking pace, and Node.js is shipping out a new version frequently. It is nice to have the latest version at hand in your development environment to test out new features.

There are a few ways to install Node.js. One of the obvious ones is to download the installer from nodejs.org. However, you might not want to be downloading a new installer every time there’s a new version out.

Here are few alternative ways to update to the latest version of Node.js on a Mac.

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.

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

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.

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.

MacPorts

MacPorts is the other 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 a previous version of the package installed.

There also exists nodejs alternative to nodejs-devel that follows the long term support line.

Node doesn’t wait for your database call to finish?

Learn how asynchronous calls work and make your app run as you intended. Get short email course on asynchronicity and two chapters from Finish Your Node App.

Источник

How to Update Node Version In Mac In 2022

Right now, Node.js version 16.8.0 is the latest, and yours might be different depending on when you are reading this article. Web Development is changing rapidly. Development is picking at a rapid pace, and Node.js is shipping out the new version to almost everyone; therefore, it is nice to have the latest version at hand in your development environment to test out the new features and also made it compatible with other Javascript libraries.

Why you should upgrade the node

Well, you have many reasons that why you should update the node to the latest version because the Javascript community is getting bigger and bigger, and so does the NPM repository.

All the new JS frameworks and libraries require the latest node.js version because they are built on the latest technology, and to keep up with that. You also need to update all of your outdated libraries, especially Node.js.

Let me give you a scenario, and if you are using the current date’s latest version of React, which is React 16.2.0, and you have a node.js version of, let say 9.0, then you won’t be able to even install the React.js project due to some outdated libraries of node.js.

You do need to update to the latest version to even work with other JS libraries and frameworks.

Читайте также:  Как запустить диагностику компьютера windows 10

Even node.js is improving from their previous version, so there are many reasons to upgrade your node.js to the latest version. Getting left behind will be the never option for yours.

How to Update Node Version on Mac

Okay, so we have seen why do we need to update Node.js, but the next question is how we are going to do it.

Well, three ways can do that job.

Update Node using N

It is the simplest way.

N is an npm-based node version manager.

I am assuming that you already have some version of node is installed on your machine.

You can install it by installing the first version of the node and then running the following command.

Assuming you have successfully installed n.

The following command will install the latest version of the node. Please hit that command in admin mode.

It will install the latest version of Node.js.

Update Node.js using Homebrew

Homebrew is one of the popular package managers for MacOS.

Assuming you have previously installed node with.

You can get up-to-date with formulae and upgrade to the latest Node.js version with the following command.

It will install the latest version of Node.js.

Update Node using NVM

Nvm is the script-based node version manager.

You can install it easily with the curl and bash one-liner as described in the documentation.

It’s also available on the Homebrew package manager.

You can install NVM using Homebrew using the following command.

Now the following command will install the latest version of the node.

The last option installs all the global npm packages over to your new version.

This way, the packages like mocha and node-inspector keep working.

Conclusions

Upgrading node to the latest version is kid’s stuff, but if you are running in trouble, you can always switch the way to update it.

If you are running in trouble using homebrew, please update the homebrew first and then install one by one missing dependency. It will work fine only after it has all the required dependencies.

Источник

Обновите Node.js до последней версии в Mac OS

В настоящее время я использую Node.js v0.6.16 на Mac OS X 10.7.4. Теперь я хочу обновить его до последней версии Node.js v0.8.1. Но после загрузки и установки последнего файла пакета с nodejs.org, я обнаружил, что система все еще использует v0.6.16 вместо v0.8.1, когда я набрал «node -v» в терминале. Есть ли какой-то шаг, который я пропустил? Или мне следует полностью удалить старую версию перед установкой последней?

Кстати, я знаю, что nvm может помочь в управлении пакетом nodejs

Есть ли способ обновить Node.js без его использования?

Я погуглил эту проблему, но мне кажется, что нет четкого ответа на этот вопрос для последней версии Node.js. Большое спасибо.

20 ответов

Вот как я успешно обновился с v0.8.18 до v0.10.20 без каких-либо других требований , таких как brew и т. д. (введите эти команды в терминале):

  1. sudo npm cache clean -f (принудительно) очистить кэш npm
  2. sudo npm install -g n установить «n» (это может занять некоторое время)
  3. sudo n stable обновить до последней версии

Обратите внимание, что sudo может запросить ваш пароль.

Если номер версии не отображается при вводе node -v , возможно, вам придется перезагрузиться.

эти инструкции также находятся здесь: davidwalsh.name/upgrade-nodejs

Если вы изначально установили Node.js с помощью Доморощенный , запустите:

Или как однострочник:

Примечание. Если у вас есть npm —version update (выше) на install

Удобный способ изменить версии — использовать nvm :

Чтобы установить последнюю версию Node.js с помощью nvm:

Если вы установили с помощью пакета, загрузите последнюю версию с nodejs. орг . См. Установка Node.js и обновление npm .

Поскольку это, по-видимому, на первом месте в Google при поиске способов обновления nodejs на Mac, я предложу свой совет всем, кто придет в будущем, несмотря на его возраст.

Обновление через NPM
Вы можете использовать метод, описанный @Mathias выше, или выбрать следующий более простой метод через терминал.

Читайте также:  Как посмотреть результаты chkdsk windows

После чего вы можете подтвердить обновление

Ваши nodejs должны быть обновлены до последней версии. Если вы хотите перейти на конкретную версию, скажите v0.8.19, а не

ИЗМЕНИТЬ Избегайте использования sudo, если вам не нужно. См. Комментарий Стива в комментариях

Перейдите на http://nodejs.org и загрузите и запустите установщик. Это работает сейчас — по крайней мере для меня.

Вы можете установить nvm и установить несколько версий Node.js.

а затем запустите:

вы можете увидеть, с какими версиями вы установили:

и вы можете переключаться между версиями с помощью:

Преимуществом использования NVM является то, что вы можете тестировать разные версии вместе. Если для разных приложений требуются разные версии Node.js, вы можете запустить их оба.

Я использую менеджер версий Node (называемый n) для него.

Просто зайдите на сайт JS Website и установите последнюю версию.

Установите последнюю версию вместо рекомендуемой стабильной версии. Это даст вам свободу использовать новейшие функции ES6 на узле.

Можно найти здесь узел JS .

также для обновления npm вам придется использовать эту команду.

Все ваши проекты будут работать нормально.

Другая опция для mac :: brew update && brew install node && npm -g npm

В macOS рекомендуемый способ для доморощенного — запустить

Я могу обновить узел, используя следующую команду

к сожалению, n не работает для меня. Я использую node version manager or nvm , и это работает как шарм. вот ссылка на то, как установить nvm : https://github.com/creationix/nvm#installation

  • nvm i 8.11.2 обновить до последней LTS
  • nvm use 8.11.2 используйте его
  • node -v проверьте свою последнюю версию

Перейдите на веб-сайт nodejs.org и загрузите последнюю версию pkg, а затем установите. это работает для меня

Я использовал brew для обновления своего узла. Он установлен, но находится в /usr/local/Cellar/node/5.5.0 , а в /usr/local/bin/node что меня беспокоит. Я не хочу делать мягкую ссылку, потому что я действительно не знаю, как устроен варево. Поэтому я скачал файл pkg , и получил эту информацию:

Node.js был установлен в

npm был установлен в

Убедитесь, что /usr/local/bin в вашей переменной $ PATH.

Теперь обновление завершено

Вы можете просто зайти на nodejs.org и загрузить новейший пакет. Он будет обновляться соответствующим образом для вас. NPM также будет обновлен.

Вы можете запустить, но не можете спрятаться . В конце вы будете использовать NVM в любом случае.

Я думаю, что самый простой способ использовать новейшую версию Node.js — это получить новейший файл pkg Node.js на веб-сайте https://nodejs.org/en/download/current/ если вы хотите использовать другую версию Node.js, вы можете использовать nvm или n для управления ею.

Nvm Nvm — это менеджер версий узлов на основе сценариев. Вы можете легко установить его с помощью однострочного скручивания и загибания, как описано в документации. Это также доступно на Homebrew.

Если вы успешно установили nvm. Ниже будет установлена ​​последняя версия узла.

Последний вариант устанавливает все глобальные пакеты npm в вашу новую версию. Таким образом, такие пакеты, как mocha и node-inspector продолжают работать.

Н N — менеджер версий узлов на основе npm. Вы можете установить его, установив сначала некоторую версию узла, а затем запустив npm install -g n .

Если вы успешно установили n. Ниже будет установлена ​​последняя версия узла.

Homebrew Homebrew — один из двух популярных менеджеров пакетов для Mac. Предполагая, что вы ранее установили узел с узлом установки brew. Вы можете получить последние сведения о формулах и перейти на последнюю версию Node.js, выполнив следующие действия.

MacPorts MacPorts — еще один менеджер пакетов для Mac. Далее будет обновлено дерево локальных портов, чтобы получить доступ к обновленным версиям. Затем будет установлена ​​последняя версия Node.js. Это работает, даже если у вас установлена ​​предыдущая версия пакета.

Используйте nvm для обновления узла в соответствии с требованиями проекта.

установите nvm через homebrew .. заваривать обновление Brew установить NVM mkdir

В своем файле .bash_profile (возможно, вы используете другой файл, в зависимости от вашей оболочки), добавьте следующее:

Источник

как обновить npm на macOS

кажется, многие нашли этот вопрос полезным, поэтому я уверен, что ответы помогут вам на правильном пути.

для моей первоначальной ситуации было две версии npm (и узел.js) установлен на моем mac. По какой-то причине одна из версий была чрезвычайно надоедливой и не удалялась.

Читайте также:  Как пересобрать ядро для linux

мое решение требовало добавления моего PATH переменная с установленной версией под

/.nvm/ как показывает принятый ответ. Это означает, что я решил свою проблему, установив node (и таким образом npm ) через nvm. Затем я обновил npm С npm i -g npm@latest без проблем.

Итак, только потому, что я не уверен, что эта преамбула ясна, я 1) установленный узел / npm с nvm,2) добавлена моя переменная $PATH. Оба шага вместе решили мою проблему.

Мой Оригинал Вопрос

по неизвестным мне причинам я не смог обновить до последней версии npm на macOS (он отлично работает на Windows). он не отображает ошибку, только «обновленный 1 пакет».

Через Узел.js 8.11.1

какая версия npm у меня есть?

я попытался это.

и он не обновляется.

поэтому я стараюсь brew .

и он терпит неудачу.

и тогда я попробовал это.

и он терпит неудачу.

С sudo :

и он терпит неудачу.

это также не удается.

я последовал за направления найдено на этом Q & A, полностью удалив npm и node из моей системы и переустановив их с нуля, а также не удается обновить.

скриншот, по запросу:

закройте терминал и снова откройте терминал, затем запустите:

Источник

how to update npm on macOS

For reasons unknown to me, I haven’t been able to update to the latest version of npm on macOS (it works fine on Windows). It displays no error, only ‘updated 1 package’.

Using Node.js 8.11.1

What version of npm do I have?

And it fails to update.

*And then I tried this. *

With sudo :

This also fails.

I followed the directions found on this Q&A, completely removing npm and node from my system and reinstalling them from scratch, and it also fails to update.

Screenshot, per request:

Close the terminal, and then re-open the terminal and running:

What did I miss? What’s going on here?

7 Answers 7

This works on my mac.

There is a note stated on the docs that depends on your installation method, you might addd some sudo .

(You may need to prefix these commands with sudo, especially on Linux, or OS X if you installed Node using its default installer.)

Perhaps you have already solved this, but here is what I found when I had exactly this issue. I had 2 versions of npm installed.

I verified this as follows:

I worked around the issue by updating the path in my bash profile, but would like to know why (how) I ended up with 2 versions. Here is the update:

npm install -g npm@latest works fine!! and you can also replace the latest for specific versions like npm install -g npm@5.6.0

I hope it will help.

In my case, none of the previous answers worked. For me, a working solution was a simple, five-step process.

  1. Make sure (the old version of) npm is installed.

If npm is not installed, then install it on the Mac with Node.js.

  1. Globally installed the desired version of npm.

This command uses the old version of npm (installed by Node), to globally install the latest version of npm at

/.npm-global/ . Once installed, close and open a new terminal shell.

  1. Remove the old version of npm installed by Node

Sometimes this doesn’t work, so I had to go into finder to delete the /npm/ folder.

  1. Make sure to set the correct path variable.

/.npm-global/bin does not show up between the colons, then update the path variable. Open up

/.zshrc in a text editor and add the following line. If you don’t use zsh, open the profile for your corresponding shell (i.e.

Save your changes and close the text editor.

  1. Close and reopen the terminal shell and run npm -v to check that npm is correctly on the latest version.

The reason for updating the path variable is because the npm cli suggests you update npm with npm install -g npm which will install npm at a different location than where Node installs npm originally.

Источник

Оцените статью