Nativescript-cli: Unable to run my application

Created on 5 Jun 2017  路  6Comments  路  Source: NativeScript/nativescript-cli

Hello guys,
I am using for first time your great framework. I am trying to build and run my application on an android emulator on ubuntu machine, but i am still getting this error after each execute of tns run android

Error: watch /home/geotzinos/projects/testapp/app ENOSPC
    at exports._errnoException (util.js:1018:11)
    at FSWatcher.start (fs.js:1443:19)
    at Object.fs.watch (fs.js:1470:11)
    at createFsWatchInstance (/home/geotzinos/.nvm/versions/node/v6.10.3/lib/node_modules/nativescript/node_modules/chokidar/lib/nodefs-handler.js:37:15)
    at setFsWatchListener (/home/geotzinos/.nvm/versions/node/v6.10.3/lib/node_modules/nativescript/node_modules/chokidar/lib/nodefs-handler.js:80:15)
    at FSWatcher.NodeFsHandler._watchWithNodeFs (/home/geotzinos/.nvm/versions/node/v6.10.3/lib/node_modules/nativescript/node_modules/chokidar/lib/nodefs-handler.js:228:14)
    at FSWatcher.NodeFsHandler._handleDir (/home/geotzinos/.nvm/versions/node/v6.10.3/lib/node_modules/nativescript/node_modules/chokidar/lib/nodefs-handler.js:407:19)
    at FSWatcher.<anonymous> (/home/geotzinos/.nvm/versions/node/v6.10.3/lib/node_modules/nativescript/node_modules/chokidar/lib/nodefs-handler.js:455:19)
    at FSWatcher.<anonymous> (/home/geotzinos/.nvm/versions/node/v6.10.3/lib/node_modules/nativescript/node_modules/chokidar/lib/nodefs-handler.js:460:16)
    at FSReqWrap.oncomplete (fs.js:123:15)

I am wondering why it runs without problems when i use your deprecated tns emulate android.

question

Most helpful comment

@gtzinos there are several possible reasons for this error:

  • the first is the discussed above - not enough space on the volume which can be checked with $ df -h (the used space should not be at 100%)
  • the second possibility is that you have reached the maximum of iNodes on your MAC/Linux machine. You can check this with $ df -i -h
  • the third possibility and perhaps the most likely one is that both Mac and Linux has limits of how many watchers they can execute. When we are watching a directory, the OS is executing a watcher for each separate file. Now the tricky moment is that in some Linux distributions the maximum limit of these watchers is 8096 which is not enough for an Angular based project where the number of files needed to be watched is bigger. This can be checked with the following command:
cat /proc/sys/fs/inotify/max_user_watches

The limit can be expanded with the following command:

echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p

All 6 comments

@gtzinos Thank you for your interest in NativeScript!

ENOSPC node error usually means that there is no space on the drive, so make sure that you have enough space in the working directory

Thank you for your information. I am currently using an ssd which is formatted before 1-2 days, so i mean that it has more space. Maybe a problem with android emulator space, i will check it now.

Nothing. My app can start but in the console i am still getting the same error message.

@gtzinos there are several possible reasons for this error:

  • the first is the discussed above - not enough space on the volume which can be checked with $ df -h (the used space should not be at 100%)
  • the second possibility is that you have reached the maximum of iNodes on your MAC/Linux machine. You can check this with $ df -i -h
  • the third possibility and perhaps the most likely one is that both Mac and Linux has limits of how many watchers they can execute. When we are watching a directory, the OS is executing a watcher for each separate file. Now the tricky moment is that in some Linux distributions the maximum limit of these watchers is 8096 which is not enough for an Angular based project where the number of files needed to be watched is bigger. This can be checked with the following command:
cat /proc/sys/fs/inotify/max_user_watches

The limit can be expanded with the following command:

echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p

Great, that was a good point to start searching for this issue. The problem was that my machine had some smaller configuration than your requirements, i follow the istructions of the second answer (https://stackoverflow.com/questions/22475849/node-js-error-enospc) :

echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p

Thank you very much for your help, as i see we found the same solution.

Was this page helpful?
0 / 5 - 0 ratings