breautek commented on issue #384: URL: https://github.com/apache/cordova/issues/384#issuecomment-1506747916
> Do you have a doc to install cordova with `nvm' ? No, the cordova docs just has a brief mention regarding nvm. This should still work on a multi-user machine, but NVM will only be installed for your user. If this is a multi-user university machine however, and all users should have access to Node, then NVM might not be the best option. NVM is just a node manager so you can then install different versions of node at the user-level. For example, if you want to use Node 16 by default, then you would do: ``` nvm install 16 nvm alias default 16 ``` You can have multiple versions installed at the same time and switch between them (every Node install have their own global packages folder) ``` nvm install 18 nvm use 18 # now node/npm references are using Node 18 for the active session, but a new terminal will still 16 as the default as configured above ``` Because Node is user level, you don't need `root` or `sudo` to install global packages because they get installed at a user-level directory (inside `~/.nvm`). e.g. you can run `npm install -g cordova` > I cant install cordova for all students NVM is a user-level (shell) program, it won't be installed for all students. Any node versions installed through NVM is also user-level install, only your user has access to it. Additionally because of this, you can now use `npm install -g <package>` without using `root` or `sudo` because these packages are installed under a nvm user-level directory. For example: ``` $ which node /home/norman/.nvm/versions/node/v18.15.0/bin/node $ which cordova /home/norman/.nvm/versions/node/v18.15.0/bin/cordova ``` To install NVM, see their [installation](https://github.com/nvm-sh/nvm#installing-and-updating) If you don't want to use NVM, it is also possible to configure NPM to not use a system directory which requires `root` by setting the [prefix](https://docs.npmjs.com/cli/v9/commands/npm-prefix?v=true) option. This config can be set to a user directory such as `~/.npm-globals` so that when you install global packages, it won't require `sudo`. But it sounds like you want a local user node install, not a system wide node install, so using NVM would be a way to achieve that. From a security standpoint, using NVM or at least configuring NPM to not use `root` owned directories is beneficial because it means you don't need to use `sudo` when installing. The drawback of requiring `sudo` is that you're giving many packages `root` level privileges during the installation, so you're making your self vulnerable to malicious packages that could do wide harm to the machine in general while running under root. -- 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. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
