You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by GitBox <gi...@apache.org> on 2019/03/19 23:16:18 UTC

[GitHub] [cordova-docs] ttimmy edited a comment on issue #838: Docs should not encourage global npm installation

ttimmy edited a comment on issue #838: Docs should not encourage global npm installation
URL: https://github.com/apache/cordova-docs/issues/838#issuecomment-474612494
 
 
   Hello.
   Got here after I ran into problems installing cordova on Ubuntu Xenial LTS. This issue is currently labeled as "enhancement," and I think it should be escalated to an actual bug in the documentation.
   
   Following the instructions on installing cordova using sudo on Ubuntu doesn't work. I installed a fresh Ubuntu 16.04 machine in VirtualBox (Node 10), and here is what happens when trying to create the HelloWorld project:
   ```
   cordova create hello com.example.hello HelloWorld
   
   /usr/lib/node_modules/cordova/node_modules/insight/node_modules/configstore/index.js:53
   				throw err;
   				^
   
   Error: EACCES: permission denied, open '/home/ubuntu16/.config/configstore/insight-cordova.json'
   You don't have access to this file.
   
       at Object.openSync (fs.js:438:3)
       at Object.readFileSync (fs.js:343:35)
       at Configstore.get (/usr/lib/node_modules/cordova/node_modules/insight/node_modules/configstore/index.js:34:26)
       at new Configstore (/usr/lib/node_modules/cordova/node_modules/insight/node_modules/configstore/index.js:27:45)
       at new Insight (/usr/lib/node_modules/cordova/node_modules/insight/lib/index.js:38:34)
       at Object.<anonymous> (/usr/lib/node_modules/cordova/src/telemetry.js:26:15)
       at Module._compile (internal/modules/cjs/loader.js:701:30)
       at Object.Module._extensions..js (internal/modules/cjs/loader.js:712:10)
       at Module.load (internal/modules/cjs/loader.js:600:32)
       at tryModuleLoad (internal/modules/cjs/loader.js:539:12)
   ```
   
   I tried to install without sudo and:
   
   ```
   ubuntu16@ubuntu16-VirtualBox:~$ npm install -g cordova
   npm WARN checkPermissions Missing write access to /usr/lib/node_modules
   npm ERR! path /usr/lib/node_modules
   npm ERR! code EACCES
   npm ERR! errno -13
   npm ERR! syscall access
   npm ERR! Error: EACCES: permission denied, access '/usr/lib/node_modules'
   npm ERR!  { [Error: EACCES: permission denied, access '/usr/lib/node_modules']
   npm ERR!   stack:
   npm ERR!    'Error: EACCES: permission denied, access \'/usr/lib/node_modules\'',
   npm ERR!   errno: -13,
   npm ERR!   code: 'EACCES',
   npm ERR!   syscall: 'access',
   npm ERR!   path: '/usr/lib/node_modules' }
   npm ERR! 
   npm ERR! The operation was rejected by your operating system.
   npm ERR! It is likely you do not have the permissions to access this file as the current user
   npm ERR! 
   npm ERR! If you believe this might be a permissions issue, please double-check the
   npm ERR! permissions of the file and its containing directories, or try running
   npm ERR! the command again as root/Administrator (though this is not recommended).
   
   npm ERR! A complete log of this run can be found in:
   npm ERR!     /home/ubuntu16/.npm/_logs/2019-03-19T22_22_56_331Z-debug.log
   ```
   
   I tried searching this project for "EACCES" and "cordova-insight" to see if I'm the only one with this problem. I found no results, but since this is a brand new Ubuntu setup I don't think it's just on my end. I'm finding a lot of stuff in stackoverflow about sudo, npm and permissions. So I'm aware there is an issue here, but I think the docs should either have a working set of instructions, or at least mention that installing on Ubuntu is currently not officially supported. 
   
   The docs have a paragraph about npm and sudo, but the link to "more tips" directs to justjs.com, which is no longer active.
   
   Reading this issue, I can understand that there is an alternative (npx) which I'm going to read on now. As I said in the beginning, I'm posting this because I think this should be escalated from "enhancement" to something more.
   
   Thanks for all the hard work!
   
   P.S.
   I wanted to upload the screencast of installation, but Github only accepts GIFs, so hope this helps:
   ![ezgif-2-31a1aa2c27c3](https://user-images.githubusercontent.com/10391916/54645852-ab786780-4a73-11e9-9996-be1b32300ce9.gif)
   
   Edit:
   P.P.S:
   I tried a new Ubuntu installation again, but this time installed npx. I'm listing the steps here in case anybody comes here looking for answers.
   After installing Node (current LTS is 10), run the following:
   ```
   sudo npm install -g npx
   ```
   Next, try to create the cordova project via npx (you will get an error):
   ```
   npx cordova create hello com.example.hello HelloWorld
   ```
   Follow the error's instructions on changing permissions on your ```.config``` folder (the command ```sudo chown...```). I can't paste it for you here because the path varies according to your home folder name.
   Now try creating the project again:
   ```
   npx cordova create hello com.example.hello HelloWorld
   ```
   After being asked about telemetry permissions, you'll be good to go. Just use ```npx cordova``` instead of ```cordova``` from now on.
   Disclaimer: This worked for me and it got the project created. Try creating platforms, building, debugging etc. your project before relying on this any further.
   
   If the maintainers of the docs approve, I suggest creating a link to this issue (and in particular this comment) to replace the old broken link ("more tips") that exists in the docs now.
   
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org