{"_id":"5845d04a8584d02500ec8e58","version":{"_id":"582789aabe5c080f00a5a7fe","__v":10,"project":"568bdc1483d2061900d86cdc","createdAt":"2016-11-12T21:29:14.915Z","releaseDate":"2016-11-12T21:29:14.915Z","categories":["582789abbe5c080f00a5a7ff","582789abbe5c080f00a5a800","582789abbe5c080f00a5a801","582789abbe5c080f00a5a802","582789abbe5c080f00a5a803","582789abbe5c080f00a5a804","582789abbe5c080f00a5a805","582789abbe5c080f00a5a806","582789abbe5c080f00a5a807","582789abbe5c080f00a5a808","5827ea984ca29e0f00137a9e","583df597887db62f00644283","583df5d9c622791900e78da5","5845cd8763c11b250037967d","5845d13063c11b2500379681","5859e859e3306d1900126725","587aeb9a01cf3a0f008359eb","587c422af45e2d0f005e200d","587d84dc82f6f30f004ceee5"],"is_deprecated":false,"is_hidden":false,"is_beta":true,"is_stable":true,"codename":"beta2","version_clean":"0.0.0","version":"0"},"parentDoc":null,"project":"568bdc1483d2061900d86cdc","user":"578ef2353ac44e0e0095075c","category":{"_id":"5845cd8763c11b250037967d","__v":0,"project":"568bdc1483d2061900d86cdc","version":"582789aabe5c080f00a5a7fe","sync":{"url":"","isSync":false},"reference":false,"createdAt":"2016-12-05T20:26:47.096Z","from_sync":false,"order":6,"slug":"setup-instructions","title":"Setup Instructions"},"__v":0,"updates":[],"next":{"pages":[],"description":""},"createdAt":"2016-12-05T20:38:34.403Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"settings":"","results":{"codes":[]},"auth":"required","params":[],"url":""},"isReference":false,"order":1,"body":"To download NodeJS for macOS, head over to https://nodejs.org/en/download/current/\n\nAt the time of writing this article, the current version of NodeJS is 7.2.0 and NPM is 3.10.9.\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/470a0fa-Screen_Shot_2016-12-05_at_3.51.51_PM.png\",\n        \"Screen Shot 2016-12-05 at 3.51.51 PM.png\",\n        1195,\n        891,\n        \"#dde8e3\"\n      ]\n    }\n  ]\n}\n[/block]\nDownload and run the **macOS Installer (.pkg)**\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": []\n    }\n  ]\n}\n[/block]\n\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/0185ff7-Screen_Shot_2016-12-05_at_3.42.26_PM.png\",\n        \"Screen Shot 2016-12-05 at 3.42.26 PM.png\",\n        732,\n        550,\n        \"#e9e9e9\"\n      ]\n    }\n  ]\n}\n[/block]\nBy default NodeJS will install to `/usr/local/bin/node` and NPM will install to `/usr/local/bin/npm`\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/e0ceef3-Screen_Shot_2016-12-05_at_3.40.07_PM.png\",\n        \"Screen Shot 2016-12-05 at 3.40.07 PM.png\",\n        732,\n        550,\n        \"#e9e9e8\"\n      ]\n    }\n  ]\n}\n[/block]\nYou can check that NodeJS and NPM are installed correctly by confirming their version numbers from **Terminal** by running `node -v` and `npm -v`.\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/450ca18-Screen_Shot_2016-12-05_at_3.53.34_PM.png\",\n        \"Screen Shot 2016-12-05 at 3.53.34 PM.png\",\n        617,\n        478,\n        \"#040404\"\n      ]\n    }\n  ]\n}\n[/block]\nYou can test NodeJS by running it interactively. From Terminal enter `node`, then `console.log(\"Helloworld!\");`\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/30c005a-Screen_Shot_2016-12-05_at_4.15.23_PM.png\",\n        \"Screen Shot 2016-12-05 at 4.15.23 PM.png\",\n        589,\n        450,\n        \"#040404\"\n      ]\n    }\n  ]\n}\n[/block]\nYou will need to complete the next section if you wish to install npm packages globally.\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Installing Node modules globally\"\n}\n[/block]\nYou can install some npm packages globally, such as the [droplit.io CLI](https://www.npmjs.com/package/droplit-cli), to run them from any directory. \n\n`npm install droplit-cli -g`\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/689c481-Screen_Shot_2016-12-05_at_9.13.11_PM.png\",\n        \"Screen Shot 2016-12-05 at 9.13.11 PM.png\",\n        589,\n        492,\n        \"#eff0ec\"\n      ]\n    }\n  ]\n}\n[/block]\nHowever, you may encounter an error like this when installing npm packages globally.\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/f52421c-Screen_Shot_2016-12-05_at_6.34.34_PM.png\",\n        \"Screen Shot 2016-12-05 at 6.34.34 PM.png\",\n        617,\n        478,\n        \"#e2d5d6\"\n      ]\n    }\n  ]\n}\n[/block]\nThere are a few ways to solve this issue according to [docs.npmjs.com](https://docs.npmjs.com/getting-started/fixing-npm-permissions). We prefer Option 2 as it does not require changing directory ownership, which may be a security risk.\n\nFirst, change the install location of global packages.\n```\nmkdir ~/.npm-global\nnpm config set prefix '~/.npm-global'\n```\n\nFinally, create/edit `.bashrc` to add the new directory to your `PATH`. \n\n```\necho \"export PATH=~/.npm-global/bin:\\$PATH\" >> ~/.bashrc\n```\n\nRestart your terminal and you should be able to install and use global packages. \n[block:callout]\n{\n  \"type\": \"info\",\n  \"title\": \"You can use .bash_profile instead of .bashrc if you wish.\",\n  \"body\": \"The `.bash_profile` is only executed for a login-shell, whereas `.bashrc` is executed for every new shell instance\"\n}\n[/block]","excerpt":"","slug":"install-nodejs-on-mac-os","type":"basic","title":"Install Node.js on macOS"}

Install Node.js on macOS


To download NodeJS for macOS, head over to https://nodejs.org/en/download/current/ At the time of writing this article, the current version of NodeJS is 7.2.0 and NPM is 3.10.9. [block:image] { "images": [ { "image": [ "https://files.readme.io/470a0fa-Screen_Shot_2016-12-05_at_3.51.51_PM.png", "Screen Shot 2016-12-05 at 3.51.51 PM.png", 1195, 891, "#dde8e3" ] } ] } [/block] Download and run the **macOS Installer (.pkg)** [block:image] { "images": [ { "image": [] } ] } [/block] [block:image] { "images": [ { "image": [ "https://files.readme.io/0185ff7-Screen_Shot_2016-12-05_at_3.42.26_PM.png", "Screen Shot 2016-12-05 at 3.42.26 PM.png", 732, 550, "#e9e9e9" ] } ] } [/block] By default NodeJS will install to `/usr/local/bin/node` and NPM will install to `/usr/local/bin/npm` [block:image] { "images": [ { "image": [ "https://files.readme.io/e0ceef3-Screen_Shot_2016-12-05_at_3.40.07_PM.png", "Screen Shot 2016-12-05 at 3.40.07 PM.png", 732, 550, "#e9e9e8" ] } ] } [/block] You can check that NodeJS and NPM are installed correctly by confirming their version numbers from **Terminal** by running `node -v` and `npm -v`. [block:image] { "images": [ { "image": [ "https://files.readme.io/450ca18-Screen_Shot_2016-12-05_at_3.53.34_PM.png", "Screen Shot 2016-12-05 at 3.53.34 PM.png", 617, 478, "#040404" ] } ] } [/block] You can test NodeJS by running it interactively. From Terminal enter `node`, then `console.log("Helloworld!");` [block:image] { "images": [ { "image": [ "https://files.readme.io/30c005a-Screen_Shot_2016-12-05_at_4.15.23_PM.png", "Screen Shot 2016-12-05 at 4.15.23 PM.png", 589, 450, "#040404" ] } ] } [/block] You will need to complete the next section if you wish to install npm packages globally. [block:api-header] { "type": "basic", "title": "Installing Node modules globally" } [/block] You can install some npm packages globally, such as the [droplit.io CLI](https://www.npmjs.com/package/droplit-cli), to run them from any directory. `npm install droplit-cli -g` [block:image] { "images": [ { "image": [ "https://files.readme.io/689c481-Screen_Shot_2016-12-05_at_9.13.11_PM.png", "Screen Shot 2016-12-05 at 9.13.11 PM.png", 589, 492, "#eff0ec" ] } ] } [/block] However, you may encounter an error like this when installing npm packages globally. [block:image] { "images": [ { "image": [ "https://files.readme.io/f52421c-Screen_Shot_2016-12-05_at_6.34.34_PM.png", "Screen Shot 2016-12-05 at 6.34.34 PM.png", 617, 478, "#e2d5d6" ] } ] } [/block] There are a few ways to solve this issue according to [docs.npmjs.com](https://docs.npmjs.com/getting-started/fixing-npm-permissions). We prefer Option 2 as it does not require changing directory ownership, which may be a security risk. First, change the install location of global packages. ``` mkdir ~/.npm-global npm config set prefix '~/.npm-global' ``` Finally, create/edit `.bashrc` to add the new directory to your `PATH`. ``` echo "export PATH=~/.npm-global/bin:\$PATH" >> ~/.bashrc ``` Restart your terminal and you should be able to install and use global packages. [block:callout] { "type": "info", "title": "You can use .bash_profile instead of .bashrc if you wish.", "body": "The `.bash_profile` is only executed for a login-shell, whereas `.bashrc` is executed for every new shell instance" } [/block]