The simplest way to install Node.js is by QNAP App center. However the package from app center does not work correctly and in addition, the package installs the outdated version of Node.js.

When I installed Node.js from App Center, I was not able to run npm command, it always returns the error:

    throw err;
Error: Cannot find module 'npmlog'
    at Function.Module._resolveFilename (module.js:338:15)
    at Function.Module._load (module.js:280:25)
    at Module.require (module.js:362:17)
    at require (module.js:378:17)
    at /share/MD0_DATA/.qpkg/nodejs/node/bin/npm:18:11
    at Object.<anonymous> (/share/MD0_DATA/.qpkg/nodejs/node/bin/npm:86:3)
    at Module._compile (module.js:449:26)
    at Object.Module._extensions..js (module.js:467:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)

After several hours of looking on the internet and struggling with installation, I found a way that worked for me:

1. Install the Node.js by QNAP App Center
2. Open SSH to your QNAP and login by admin user
For Mac, open terminal and type: ssh {QNAP IP} -l admin
For Windows you can use PuTTY tool from the site: Download page
3. Run the commands:

cd /share/MD0_DATA/.qpkg/nodejs
tar zxf node-v0.10.32-linux-x86.tar.gz
mv node node-v0.8.22
ln -s node-v0.10.32-linux-x86 node
npm version

Script explanation:
Line:2 – download the latest version of Node.js, you can change version “v0.10.32” in the line to any version of Node.js from their site: Node.js
Line:3 – uncompress the downloaded file, put attention on version in case you changed it.
Line:4 – move old files to tmp directory.
Line:5 – create a link with name “node” to the new version of Node.js, you should put attention on the version in name, in case you changed it.
Line:6 – the command will display current Node.js version. In my case the output was:

{ http_parser: '1.0',
  node: '0.10.32',
  v8: '',
  ares: '1.9.0-DEV',
  uv: '0.10.28',
  zlib: '1.2.3',
  modules: '11',
  openssl: '1.0.1i',
  npm: '1.4.28' }

4. If you try to run any complicated command like “npm install -g grunt-cli” now, you will get an error:

Error: setuid user id does not exist
    at /share/MD0_DATA/.qpkg/nodejs/node-v0.10.32-linux-x86/lib/node_modules/npm/node_modules/uid-number/uid-number.js:44:16
    at ChildProcess.exithandler (child_process.js:646:7)
    at ChildProcess.emit (events.js:98:17)
    at maybeClose (child_process.js:756:16)
    at Socket.<anonymous> (child_process.js:969:11)
    at Socket.emit (events.js:95:17)
    at Pipe.close (net.js:465:12)

The problem is QNAP lacks couple of system users available on Linux systems and does not support get or set user-id. So we should modify Node.js source code.
Run the command (put attention on the version of Node.js):

vi /share/MD0_DATA/.qpkg/nodejs/node-v0.10.32-linux-x86/lib/node_modules/npm/node_modules/uid-number/uid-number.js

The command will open “uid-number.js” file in vi editor.

You should change line (you can enter to edit mode by pressing “i”):
,uidSupport = process.getuid && process.setuid
,uidSupport = false
on Line 11 in the file.

Save the file by pressing “Esc” -> “Shift” + “:” -> “w” -> “q”

This is it,
Enjoy Node.js latest version.

P.S. As per several comments, different QNAP machines has different paths to “.qpkg” folder. On my machine I have …./MD0_DATA/…, however it can be …/MDA_DATA/…, …/CACHEDEV1_DATA/… and so on.


I tried to install the pm2 package globally like it described in this article: Running NodeJS app on QNAP NAS via pm2. And I had the same issue on my QNAP as the Sergei. I was not able to run this package after installation. I tried Sergei’s solution with nodejs installing and it did not work on my TS-239 ProII. So I returned to my steps and at the end, I added the nodejs bin path to PATH with the following command:

export PATH=$PATH:/share/MD0_DATA/.qpkg/nodejsv4/node/bin

This command helped me to run pm2 from any location, however, this is a temporary solution, as this path will be lost when you close terminal.
We have to add this path every time when NAS was restarted. I decided to use the solution to create as it was described by Sergei with minor changes.

1. Create custom file.
We can put all that we need in on the system partition, however, it is better to create your own custom in other location that easily for access.
I decided to follow Sergei’s steps and created my custom in shared folder:
– Create a new shared folder in FileStation (via Web UI), I called for this folder “scripts”
– Navigate to this folder from ssh and create file:

cd /share/MD0_DATA/scripts
chmod +x

– add to file the export commands:


press ‘i’ to start file editing and add this content:

#set environment variables
echo "export PATH=$PATH" >> /etc/profile

Save the file by pressing “Esc” -> “Shift” + “:” -> “w” -> “q”

2. Create in system partition:
To create the file on system partition we have to find the name of this partition and mount this partition to have access. Let’s find this partition name, we can use the following command:

parted $(getcfg system 'System Device') print

This command has this output on my machine:

Model:  USB DISK MODULE (scsi)
Disk /dev/sdx: 516MB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Number  Start   End     Size    Type      File system  Flags
 1      16.4kB  2228kB  2212kB  primary   ext2
 2      2228kB  250MB   248MB   primary   ext2
 3      250MB   498MB   248MB   primary   ext2
 4      498MB   516MB   17.4MB  extended
 5      498MB   507MB   8503kB  logical   ext2
 6      507MB   516MB   8897kB  logical   ext2

You need the second line (Disk /dev/sdx: 516MB) from this output for the next command:

mount -t ext2 /dev/sdx6 /tmp/config

Now we have access to this partition, let’s create the file and make this file runnuble:

cd /tmp/config
chmod +x

Add link to custom to this file:


press ‘i’ to start file editing and add this content:


Save the file by pressing “Esc” -> “Shift” + “:” -> “w” -> “q”

Unmount the partition:

umount /dev/sdx6

Now you can restart your QNAP and try to run pm2 from anywhere.

22 Thoughts on “QNAP – Node.js installation

  1. inktomat on November 8, 2014 at 4:58 pm said:

    Thank You! This helped tremendously.

  2. THANKS a lot Yura!

  3. Hi,

    this only works on x86 qnap machines, right? Is the a precompiled version for arm too?


  4. Hi Panshin

    Good morning, I’m Nelson , from Taiwan

    I have same question about install mongo DB on QNAP and I follow your guide to solved my.

    But did you ever been face every time I reboot my QNAP nas , need manually start mongo db with ssh, the command like is

    “mongod –dbpath=/share/HDA_DATA/.qpkq/mongo/data/db”

    I’m looking for the answer , unfortunately no one face same problem with me.

    can you tech me how can fix this.

    Thank you


    sorry, my English is very poor.

    • Hi Nelson,

      I am sorry, but I never created scripts to run it after reboot. However there are lot of examples of such scripts. Please google it.

  5. Johannes on January 2, 2015 at 5:08 pm said:

    Thanks for your detailed description. Unfortunately I got a different error message:

    /bin/npm: line 2: /bin/node: cannot execute binary file
    /bin/npm: line 2: /bin/node: Success

    I’ll come back when/if I’m able to make sense of that.

    • Johannes on January 4, 2015 at 10:23 am said:

      Ok, I did a bit of research and these are the results.

      # cd /share/HDA_DATA/.qpkg/nodejs
      # type npm
      npm is hashed (/bin/npm)
      # ls -l /bin |grep npm
      lrwxrwxrwx 1 admin administ 41 Jan 2 18:05 npm -> /share/HDA_DATA/.qpkg/nodejs/node/bin/npm*
      # ls -l node/bin |grep npm
      lrwxrwxrwx 1 admin administ 38 Jan 4 11:06 npm -> ../lib/node_modules/npm/bin/npm-cli.js*

      So `npm` links to `node/lib/node_modules/npm/bin/npm-cli.js`

      This is an executable shell script and starts with:

      # head node/lib/node_modules/npm/bin/npm-cli.js
      // 2>/dev/null; exec “`dirname “$0″`/node” “$0” “$@”

      If I understand this correctly, it tries to call `node/lib/node_modules/npm/bin/node` with `npm-cli.js` and its arguments as parameter.
      But there is no `node/lib/node_modules/npm/bin/node`.

      Any ideas?

  6. Hi,

    Struggling with this issue as well. I followed your steps which looks very straight forward. But it keeps telling me “-sh: npm: command not found”. While there was no error with downloading and uncompressing the .tar file. Do you`ve got any idea why this is?

  7. Michele on April 5, 2015 at 2:21 pm said:

    Hello, i’m trying to install node.js on my qnap.
    I’ve installed it from App center, but when I use putty for goes into
    cd /share/MD0_DATA/.qpkg/nodejs

    I can’t find the Dir MD0_DATA, i’ve only HDA_DATA, HDB_DATA etc.

    Can you help me???

    • Hmm, on my machine I have MD0_DATA, however as I can see from other comments, on some machines the .qpkg folder is on HDA_DATA.

  8. Michele on April 6, 2015 at 11:24 pm said:

    Hello, i’ve found the directory node in a subdir of HDA_DATA, i’ve tried all without error but when I type npm version i’ve a NPM error, it says me “no such file or directory”. What I’ve to do???

  9. Pingback: Install the most recent node.js version on your QNAP | node & co

  10. Hi Yura,

    Thanks so much for this. I get as far as line 5 – I’m using the most recent version, which is node-v4.2.2-linux-x86.tar.gz. But when I try

    npm version

    I get

    -sh: npm: command not found

    the symbolic link from the node folder is pointing at node-v4.2.2-linux-x86/ as it should. Any ideas?

  11. Andy Badera on July 5, 2016 at 1:10 am said:

    Thanks, still helpful currently.

  12. THANK YOU! You are so awesome! I love how you explain every line. I don’t use Linux enough, but I am tech savy and so all I need is a little explanation to help me understand what’s going on with all the commands you have me type. FYI my QNAP did not have a MD0 but I had an HDA so I used that. 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Post Navigation