[Node.js] Mac に npm をインストールする方法
- 2012 10/29
Node.js のパッケージ管理ツール npm を Mac OS X Mountain Lion へインストールする方法をメモ。
事前に nodebrew で Node.js をインストールしている前提。
・[Node.js] バージョン管理ツール nodebrew を Mac にインストールする方法
% curl https://npmjs.org/install.sh | sudo sh % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 7882 100 7882 0 0 3979 0 0:00:01 0:00:01 --:--:-- 7400 tar=/usr/bin/tar version: bsdtar 2.8.3 - libarchive 2.8.3 install [email protected] fetching: http://registry.npmjs.org/npm/-/npm-1.1.65.tgz 0.6.21-pre 1.1.65 cleanup prefix=/Users/bakorer/.nodebrew/current All clean! /Users/bakorer/.nodebrew/current/bin/npm -> /Users/bakorer/.nodebrew/current/lib/node_modules/npm/bin/npm-cli.js [email protected] /Users/bakorer/.nodebrew/current/lib/node_modules/npm It worked |
正常に npm をインストールできたか確認する。
% npm --version 1.1.65 |
npm のアンインストールは下記のコマンドを実行するだけ。
% sudo npm uninstall npm -g |
ちなみに、URLがhttpからhttpsへ変わったみたいなので注意。
httpでインストールしようとすると下記のようなエラーが出る。
% curl http://npmjs.org/install.sh | sudo sh % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 85 0 85 0 0 75 0 --:--:-- 0:00:01 --:--:-- 352 sh: line 1: syntax error near unexpected token `newline' sh: line 1: `<html>Moved: <a href="https://npmjs.org/install.sh">https://npmjs.org/install.sh</a>' |
以上です。