티스토리 뷰

nodejs.org/download 에서 맥용 설치패키지 받아서 설치 후
npm 명령어로 필요한 모듈 설치하려니
오류가 마구 쏟아지며 설치가 안되어 재설치법을 아래에 붙여둠.


Run the following commands to uninstall node.js: 

lsbom -f -l -s -pf /var/db/receipts/org.nodejs.pkg.bom | while read f; do  sudo rm /usr/local/${f}; done
 
sudo rm -rf /usr/local/lib/node /usr/local/lib/node_modules /var/db/receipts/org.nodejs.*

http://notepad2.blogspot.kr/2012/06/how-to-uninstall-nodejs-on-mac-os-x.html


Install Homebrew

Homebrew is the package manager that Apple forgot. Written in Ruby it allows you to quickly and easily compile software on your Mac. Instructions for installing Homebrew are in the README so I won't repeat them here. You will need to install Developer Tools for Mac which you are installed as part of Xcode. Xcode is available for free - it is a pretty hefty download but you'll need it.

Install Node.js via homebrew

Once Homebrew is installed you can go ahead and install Node.js

brew install node

Easy! Now create a file called server.js and paste in the example server code

var http = require('http');
http.createServer(function (req, res) {
  res.writeHead(200, {'Content-Type': 'text/plain'});
  res.end('Hello World\n');
}).listen(8124, "127.0.0.1");
console.log('Server running at http://127.0.0.1:8124/');

Save the file and from the console run

node server.js

Now you can visit http://127.0.0.1:8124/ with your favourite browser and you are up and running with server side JavaScript.

At this point it is probably a good idea to consult the excellent Node.js documentation. This will help you understand what Node.js is and what it can do.

Installing npm

npm is Node's package manager. It is now installed automatically with Node.js so there is no need to do a separate installation.

If you are developing anything in Node.js there is a good chance there is already a library to help you. It might be a module to connect to MySQL, a templating library or a utility library.

You can search for modules like this

npm search [searchterm]

So to search for underscore do this

npm search underscore

There is also a website for npm where you can search for packages.

Installing modules

Now we are set up we can install Node modules using npm. Express is a good place to start - it is a Node framework inspired by Sinatra.

npm install express

This provides a solid base to start developing with Node.js including jadethe haml inspired Node tempting engine. There is more excellent documentation available for express too.

That's it - go create!

Have an update or suggestion for this article? You can edit it here and send me a pull request.

http://shapeshed.com/setting-up-nodejs-and-npm-on-mac-osx/


위와같은 순서로 재설치 후
터미널에서 npm 모듈 설치 명령을 내렸더니
시원스럽고 깔끔하게 설치 잘 됨.

댓글