breautek commented on issue #626: URL: https://github.com/apache/cordova-cli/issues/626#issuecomment-1704254098
Ive been on MacOS Ventura 13.5 just fine. Based on the output, it's NPM failing due to permission issues. This can be caused by mixing usages of `sudo`. Once you use `sudo` you'll be installing things under your root account, which will be a source of permission issues that might not be completely obvious until you try to run commands later. The good news is, it appears that it appears that your NPM is configured to store the npm cache files under your user HOME directory, so `sudo` should not be required, but first you probably need to fix your environment. ### Step 1 - Nuking the NPM Cache Delete the NPM cache (which you've already tried, but you should do so again since it appears you used `sudo` again afterwards with NPM (via `sudo cordova platform add ....`) ` sudo npm cache clean --force` Note we are using `sudo` here just in case if there are any files/directories that is owned by root. You verify if this worked by checking if `~/.npm/_cacache` directory exists. It should have been deleted after running the cache clean command. ### Step 2 - Nuking node_modules Now, delete your node_modules, since you've been exiting out npm install commands, it may also be in a bad state. `sudo rm -rf node_modules/` I'm using `sudo` again here just in case there are directories/files owned by root in your node_modules foler. Based on your `ls` output, it doesn't look like NPM created a `package-lock.json` file, but if there is one, delete it too. ### Step 3 - Attempting to reinstall From this point on, NPM will be **SLOW**, because you have no cache. NodeJS modules are notoriously bad for having tiny little packages and for each one will now require a network hit, and will requiring download and unpacking the contents. So patience will be needed. If you like, you can use `--verbose` flag on any of `cordova` commands to see more output, which may give you more confidence that stuff is actually happening (and in likeliness, stuff will wait on NPM to complete it's work). Once NPM builds up it's cache from stuff that you commonly install it will speed up since it can install packages from cache rather than from the network. More importantly, from here on out, `sudo` is not to be used. If you use `sudo` again with any NPM or cordova commands, you may start running into permission issues again. Additionally, I don't trust your globally installed packages and additional work will be needed if you have `sudo` installed any global packages. Therefore, for the time being I'm going to instruct you to install local (project) copies of Cordova, which is actually kind of better practice to begin with. So first install cordova (without `sudo`!): `npm install cordova` Now, to use your local cordova install (instead of global) you can use the `npx` command prefix, which instructs NPM to look for the cordova exectable in your local node_modules. `npx cordova platform add browser --verbose` All of cordova documentation assumes you have a global install of `cordova`, so with the local install, `npx` command prefix will be required to run cordova, otherwise you may run your global cordova install. Let me know if this helps. -- 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]
