Forums

Want to create mobile app for pythonanywhere django web site

Hi,

I want to create a mobile app for my pythonanywhere web site. I have no experience in this and am just looking around at options. It seems many people suggest using ionic to create a hybrid mobile app. I wanted to play around with it and tried installing it (in both my virtual env and just in a regular bash console). Their website says to enter sudo npm install -g ionic but when I do get the the following error: sudo: unknown user: root. I also tried npm install -g ionic but got the following error:

npm ERR! Linux 4.4.0-1060-aws npm ERR! argv "node" "/usr/bin/npm" "install" "-g" "ionic" npm ERR! node v0.10.37 npm ERR! npm v3.10.6 npm ERR! path /usr/lib/node_modules npm ERR! code EACCES npm ERR! Error: EACCES, access '/usr/lib/node_modules' npm ERR! at module.exports (/usr/lib/node_modules/npm/lib/install/access-error.js:4:18) npm ERR! at /usr/lib/node_modules/npm/lib/install/writable.js:30:25 npm ERR! at /usr/lib/node_modules/npm/node_modules/graceful-fs/graceful-fs.js:232:16 npm ERR! at Object.oncomplete (fs.js:108:15) npm ERR! { [Error: EACCES, access '/usr/lib/node_modules'] code: 'EACCES', path: '/usr/lib/node_modules' } npm ERR! npm ERR! Please try running this command again as root/Administrator.

I then tried npm install ionic and that seemed to work but when I try any of the ionic commands I get the following message: ionic: command not found, making me think it's not really installed.

I did get the following warnings on the install:

npm WARN optional Skipping failed optional dependency /chokidar/fsevents: npm WARN notsup Not compatible with your operating system or architecture: fsevents@1.2.4 npm WARN enoent ENOENT, open '/home/myusername/package.json' npm WARN myusername No description npm WARN myusername No repository field. npm WARN myusername No README data npm WARN myusername No license field.

Am I not in the right directory when trying to run the install or not running the right command?

Thank you in advance! Also, if there are other methods you suggest for creating a mobile app and integrating with existing code on pythonanywhere please let me know.

  1. that kind of html apps for mobiles are meant to be developed in a local computer, a server like PA does little benefit to them.
  2. that said you are trying to install a node library in a global space /usr/lib, /usr/bin, that is not possible here.
  3. finally i see Not compatible with your operating system or architecture it seems that your tool is ultimately not compatible with PythonAnywhere.

If you want to run Node stuff on PythonAnywhere then your best bet is to use NVM to install a version of your choosing to your private file storage -- then when you run npm install, just skip the -g flag and it will install stuff to your local directory, which means you don't need to use sudo.

I agree with @irtusb that the Not compatible with your operating system or architecture warning is a little concerning, but it might be mis-characterising a permissions error, so it would be worth seeing if that goes away if you use NVM.

Regarding creating a mobile app to integrate with code on PythonAnywhere, you mention that you're using Django so a good way forward would be to write the mobile app to access the backend using REST, and then to write a REST API as part of your Django app. We use Django Rest Framework for our own code and are really happy with it.

Thank you! That worked!

Great! Thanks for confirming.