{"_id":"584490f4f98c4b19003f36a4","project":"568bdc1483d2061900d86cdc","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"},"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"},"parentDoc":null,"__v":2,"user":"568bdbc4fe6fcc0d006dc970","updates":["5934daea30694c002ff8cd4d","5934e02b328680002d77dcbd"],"next":{"pages":[],"description":""},"createdAt":"2016-12-04T21:56:04.947Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"settings":"","auth":"required","params":[],"url":""},"isReference":false,"order":2,"body":"[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"x86/x64 Linux Desktop\"\n}\n[/block]\nHead over to https://nodejs.org/en/download/ to get the download url to NodeJS. For this demonstration, NodeJS (v7.2.0) will be installed on Ubuntu 16.04.1.\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/ca26c74-Screenshot_from_2016-12-06_12-38-20.png\",\n        \"Screenshot from 2016-12-06 12-38-20.png\",\n        1052,\n        665,\n        \"#e7eee7\"\n      ]\n    }\n  ]\n}\n[/block]\nNext, open up **Terminal** and use `wget` to download the Linux binary.\n\n```\nwget https://nodejs.org/dist/v7.2.0/node-v7.2.0-linux-x64.tar.xz\n```\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/9b600c0-Screenshot_from_2016-12-06_12-37-28.png\",\n        \"Screenshot from 2016-12-06 12-37-28.png\",\n        746,\n        452,\n        \"#060607\"\n      ]\n    }\n  ]\n}\n[/block]\nNow use `tar` to unpack the file.\n\n```\n tar -xvf node-v7.2.0-linux-x64.tar.xz\n```\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/af7aaf2-Screenshot_from_2016-12-06_12-49-59.png\",\n        \"Screenshot from 2016-12-06 12-49-59.png\",\n        746,\n        452,\n        \"#050507\"\n      ]\n    }\n  ]\n}\n[/block]\nInstall NodeJS into `/usr/local/`.\n```\ncd node-v7.2.0-linux-x64\nsudo cp -R * /usr/local/\n```\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/28f61d9-Screenshot_from_2016-12-06_12-52-22.png\",\n        \"Screenshot from 2016-12-06 12-52-22.png\",\n        746,\n        452,\n        \"#040404\"\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\n\n```\nnode -v\nnpm -v\n```\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/c2bfe01-Screenshot_from_2016-12-06_12-53-56.png\",\n        \"Screenshot from 2016-12-06 12-53-56.png\",\n        746,\n        452,\n        \"#040404\"\n      ]\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"ARM/Raspbery Pi\"\n}\n[/block]\nDepending on which version of Raspberry PI you are using (1,2,3, Zero, etc) you will need to download the appropriate pre-compiled binary (ArmV7, ArmV8). \n\nThese instructions will show the process for a Raspberry Pi 3 (Running 2016-05-27-raspbian-jessie-lite). \n\nDownload and unpack NodeJS (ArmV7).\n\n```\nwget https://nodejs.org/dist/v7.2.0/node-v7.2.0-linux-armv7l.tar.xz\ntar -xvf node-v7.2.0-linux-armv7l.tar.xz\n```\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/e73c493-Screen_Shot_2016-12-05_at_5.13.24_PM.png\",\n        \"Screen Shot 2016-12-05 at 5.13.24 PM.png\",\n        589,\n        450,\n        \"#efefef\"\n      ]\n    }\n  ]\n}\n[/block]\n\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/02dc561-Screen_Shot_2016-12-05_at_5.13.59_PM.png\",\n        \"Screen Shot 2016-12-05 at 5.13.59 PM.png\",\n        617,\n        478,\n        \"#ecebea\"\n      ]\n    }\n  ]\n}\n[/block]\nInstall NodeJS into `/usr/local/`.\n\n```\ncd node-v7.2.0-linux-armv7l\nsudo cp -R * /usr/local/\n```\n\nAt this point you can test Node to confirm that you have installed the correct version.\n\n\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/e277122-Screen_Shot_2016-12-05_at_5.21.47_PM.png\",\n        \"Screen Shot 2016-12-05 at 5.21.47 PM.png\",\n        617,\n        478,\n        \"#040404\"\n      ]\n    }\n  ]\n}\n[/block]\n\n[block:callout]\n{\n  \"type\": \"warning\",\n  \"title\": \"Incorrect NodeJS Version\",\n  \"body\": \"If `node -v` reports something similar to `-bash: /usr/local/bin/node: cannot execute binary file: Exec format error` or does not respond, you may have installed a version of NodeJS not compatible with your operating system architecture. You can simple repeat the install process with the correct version as it will overwrite the previously installed files.\"\n}\n[/block]\nClean up the temporary files.\n\n```\ncd ~\nrm -rf node-v7.2.0-linux-armv7l\nrm node-v7.2.0-linux-armv7l.tar.xz\n```\n\nNodeJS and NPM are now installed!\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Installing Node modules globally (Linux Desktop/ Embedded)\"\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```\nnpm install droplit-cli -g\n```\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/e3786b2-Screenshot_from_2016-12-06_13-15-29.png\",\n        \"Screenshot from 2016-12-06 13-15-29.png\",\n        746,\n        452,\n        \"#040404\"\n      ]\n    }\n  ]\n}\n[/block]\nHowever, you may encounter an error like this when installing npm packages globally.\n\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/7ecea56-Screenshot_from_2016-12-06_12-57-15.png\",\n        \"Screenshot from 2016-12-06 12-57-15.png\",\n        746,\n        452,\n        \"#060707\"\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\nCreate/edit `.bashrc` to add the new directory to your `PATH`. \n\n```\necho \"export PATH=~/.npm-global/bin:\\$PATH\" >> ~/.bashrc\n```\n\nMake sure you are the owner of the `~/.npm-global/ directory, or assert your ownership using the following\n```\nchown <username>:users ~/.npm-global\n```\n\nRestart your terminal and you should be able to install and use global packages. \n[block:callout]\n{\n  \"type\": \"info\",\n  \"body\": \"The `.bash_profile` is only executed for a login-shell, whereas `.bashrc` is executed for every new shell instance\",\n  \"title\": \"You can use .bash_profile instead of .bashrc if you wish.\"\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"MIPS/OpenWRT\"\n}\n[/block]\nIf you wish to run NodeJS on an OpenWRT device and node is not already provided for your distribution or node is provided and you require a new version, you should be familiar with [OpenWrt's build system](https://wiki.openwrt.org/about/toolchain).\n\n[This article](https://github.com/netbeast/docs/wiki/Cross-Compile-Nodejs-for-OpenWrt) explains how to cross compile NodeJS for OpenWRT. \n\nOnce you have the NodeJS Binary file, transfer it to your OpenWRT device. You may need to mark it as executable. \n\n`chmod node 755`\n\nDepending on CPU speeds, we recommend downloading npm packages on a different computer and transfer them to your device. If any of your packages require compilation, you will want to compile them with your toolchain.\n\n\n[block:callout]\n{\n  \"type\": \"warning\",\n  \"body\": \"In our testing, we found that the OpenWRT kernel required FPU emulation be enabled for NodeJS to run.  Without FPU Emulation, we tested many different versions of NodeJS (0.10 - 6.0.0), and each would result in a floating point exception or not respond. When compiling your OS make sure that you have this feature enabled.\",\n  \"title\": \"FPU emulation\"\n}\n[/block]","excerpt":"","slug":"install-nodejs-on-linux","type":"basic","title":"Install Node.js on Linux/Embedded"}

Install Node.js on Linux/Embedded


[block:api-header] { "type": "basic", "title": "x86/x64 Linux Desktop" } [/block] Head over to https://nodejs.org/en/download/ to get the download url to NodeJS. For this demonstration, NodeJS (v7.2.0) will be installed on Ubuntu 16.04.1. [block:image] { "images": [ { "image": [ "https://files.readme.io/ca26c74-Screenshot_from_2016-12-06_12-38-20.png", "Screenshot from 2016-12-06 12-38-20.png", 1052, 665, "#e7eee7" ] } ] } [/block] Next, open up **Terminal** and use `wget` to download the Linux binary. ``` wget https://nodejs.org/dist/v7.2.0/node-v7.2.0-linux-x64.tar.xz ``` [block:image] { "images": [ { "image": [ "https://files.readme.io/9b600c0-Screenshot_from_2016-12-06_12-37-28.png", "Screenshot from 2016-12-06 12-37-28.png", 746, 452, "#060607" ] } ] } [/block] Now use `tar` to unpack the file. ``` tar -xvf node-v7.2.0-linux-x64.tar.xz ``` [block:image] { "images": [ { "image": [ "https://files.readme.io/af7aaf2-Screenshot_from_2016-12-06_12-49-59.png", "Screenshot from 2016-12-06 12-49-59.png", 746, 452, "#050507" ] } ] } [/block] Install NodeJS into `/usr/local/`. ``` cd node-v7.2.0-linux-x64 sudo cp -R * /usr/local/ ``` [block:image] { "images": [ { "image": [ "https://files.readme.io/28f61d9-Screenshot_from_2016-12-06_12-52-22.png", "Screenshot from 2016-12-06 12-52-22.png", 746, 452, "#040404" ] } ] } [/block] You can check that NodeJS and NPM are installed correctly by confirming their version numbers from **Terminal** by running ``` node -v npm -v ``` [block:image] { "images": [ { "image": [ "https://files.readme.io/c2bfe01-Screenshot_from_2016-12-06_12-53-56.png", "Screenshot from 2016-12-06 12-53-56.png", 746, 452, "#040404" ] } ] } [/block] [block:api-header] { "type": "basic", "title": "ARM/Raspbery Pi" } [/block] Depending on which version of Raspberry PI you are using (1,2,3, Zero, etc) you will need to download the appropriate pre-compiled binary (ArmV7, ArmV8). These instructions will show the process for a Raspberry Pi 3 (Running 2016-05-27-raspbian-jessie-lite). Download and unpack NodeJS (ArmV7). ``` wget https://nodejs.org/dist/v7.2.0/node-v7.2.0-linux-armv7l.tar.xz tar -xvf node-v7.2.0-linux-armv7l.tar.xz ``` [block:image] { "images": [ { "image": [ "https://files.readme.io/e73c493-Screen_Shot_2016-12-05_at_5.13.24_PM.png", "Screen Shot 2016-12-05 at 5.13.24 PM.png", 589, 450, "#efefef" ] } ] } [/block] [block:image] { "images": [ { "image": [ "https://files.readme.io/02dc561-Screen_Shot_2016-12-05_at_5.13.59_PM.png", "Screen Shot 2016-12-05 at 5.13.59 PM.png", 617, 478, "#ecebea" ] } ] } [/block] Install NodeJS into `/usr/local/`. ``` cd node-v7.2.0-linux-armv7l sudo cp -R * /usr/local/ ``` At this point you can test Node to confirm that you have installed the correct version. [block:image] { "images": [ { "image": [ "https://files.readme.io/e277122-Screen_Shot_2016-12-05_at_5.21.47_PM.png", "Screen Shot 2016-12-05 at 5.21.47 PM.png", 617, 478, "#040404" ] } ] } [/block] [block:callout] { "type": "warning", "title": "Incorrect NodeJS Version", "body": "If `node -v` reports something similar to `-bash: /usr/local/bin/node: cannot execute binary file: Exec format error` or does not respond, you may have installed a version of NodeJS not compatible with your operating system architecture. You can simple repeat the install process with the correct version as it will overwrite the previously installed files." } [/block] Clean up the temporary files. ``` cd ~ rm -rf node-v7.2.0-linux-armv7l rm node-v7.2.0-linux-armv7l.tar.xz ``` NodeJS and NPM are now installed! [block:api-header] { "type": "basic", "title": "Installing Node modules globally (Linux Desktop/ Embedded)" } [/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/e3786b2-Screenshot_from_2016-12-06_13-15-29.png", "Screenshot from 2016-12-06 13-15-29.png", 746, 452, "#040404" ] } ] } [/block] However, you may encounter an error like this when installing npm packages globally. [block:image] { "images": [ { "image": [ "https://files.readme.io/7ecea56-Screenshot_from_2016-12-06_12-57-15.png", "Screenshot from 2016-12-06 12-57-15.png", 746, 452, "#060707" ] } ] } [/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' ``` Create/edit `.bashrc` to add the new directory to your `PATH`. ``` echo "export PATH=~/.npm-global/bin:\$PATH" >> ~/.bashrc ``` Make sure you are the owner of the `~/.npm-global/ directory, or assert your ownership using the following ``` chown <username>:users ~/.npm-global ``` Restart your terminal and you should be able to install and use global packages. [block:callout] { "type": "info", "body": "The `.bash_profile` is only executed for a login-shell, whereas `.bashrc` is executed for every new shell instance", "title": "You can use .bash_profile instead of .bashrc if you wish." } [/block] [block:api-header] { "type": "basic", "title": "MIPS/OpenWRT" } [/block] If you wish to run NodeJS on an OpenWRT device and node is not already provided for your distribution or node is provided and you require a new version, you should be familiar with [OpenWrt's build system](https://wiki.openwrt.org/about/toolchain). [This article](https://github.com/netbeast/docs/wiki/Cross-Compile-Nodejs-for-OpenWrt) explains how to cross compile NodeJS for OpenWRT. Once you have the NodeJS Binary file, transfer it to your OpenWRT device. You may need to mark it as executable. `chmod node 755` Depending on CPU speeds, we recommend downloading npm packages on a different computer and transfer them to your device. If any of your packages require compilation, you will want to compile them with your toolchain. [block:callout] { "type": "warning", "body": "In our testing, we found that the OpenWRT kernel required FPU emulation be enabled for NodeJS to run. Without FPU Emulation, we tested many different versions of NodeJS (0.10 - 6.0.0), and each would result in a floating point exception or not respond. When compiling your OS make sure that you have this feature enabled.", "title": "FPU emulation" } [/block]