What is wrong with Ionic Auto Update?

It appears Ionic has started auto update recently.

This is the second time it asked me if I want to update. If I say NO, my apps build fails with the following message:

$ ionic cordova run android
? The Ionic CLI has an update available (3.5.0 => 3.6.0)! Would you like to ins
[OK] Not automatically updating your CLI. You can update manually:

     npm install -g ionic@latest

? Local plugin @ionic/cli-plugin-cordova has an update available (1.4.1 => 1.5.
[OK] Not automatically updating @ionic/cli-plugin-cordova. You can update
     manually:

     npm install --save-dev --save-exact @ionic/cli-plugin-cordova@latest

? Local plugin @ionic/cli-plugin-ionic-angular has an update available (1.3.2 =
[OK] Not automatically updating @ionic/cli-plugin-ionic-angular. You can update
     manually:

     npm install --save-dev --save-exact @ionic/cli-plugin-ionic-angular@latest

Running app-scripts build: --address 0.0.0.0 --port 8100 --p 8100 --livereload-port 35729 --r 35729 --iscordovaserve --externalIpRequired --nobrowser

[14:11:59]  build dev started ...
[14:11:59]  clean started ...
[14:11:59]  clean finished in 106 ms
[14:11:59]  copy started ...
[14:12:00]  transpile started ...
[14:12:13]  typescript: C:/MyApp/src/app/app.module.ts, line: 27
            Argument of type '{ declarations: (typeof UserLoginPage | typeof DashboardPage | t...' is not assignable to parameter of type 'NgModule'. Types of property
            'providers' are incompatible. Type '(typeof SplashScreen | typeof NetworkService | typeof Push...' is not assignable to type 'Provider[]'. Type 'typeof SplashScreen | typeof
            NetworkService | typeof Push...' is not assignable to type
            'Provider'. 

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            
      L28:    declarations: [

[WARN] Error occurred during command execution from a CLI plugin
       (@ionic/cli-plugin-cordova). Your plugins may be out of date.
Error: Failed to transpile program

And if I say YES, the update FAILS with following message and Ionic gets corrupted or something because of which the “ionic” command doesn’t work.

$ ionic cordova run android
? The Ionic CLI has an update available (3.5.0 => 3.6.0)! Would you like to ins
> npm install -g ionic@latest
× Running command - failed!
Exception: npm ERR! path C:\Users\myUser\AppData\Roaming\npm\ionic
npm ERR! code EPERM
npm ERR! errno -4048
npm ERR! syscall open
npm ERR! Error: EPERM: operation not permitted, open 'C:\Users\myUser\AppData\Roaming\npm\ionic'
npm ERR!     at Error (native)
npm ERR!  { Error: EPERM: operation not permitted, open 'C:\Users\myUser\AppData\Roaming\npm\ionic'
npm ERR!     at Error (native)
npm ERR!   cause:
npm ERR!    { Error: EPERM: operation not permitted, open 'C:\Users\myUser\AppData\Roaming\npm\ionic'
npm ERR!        at Error (native)
npm ERR!      errno: -4048,
npm ERR!      code: 'EPERM',
npm ERR!      syscall: 'open',
npm ERR!      path: 'C:\\Users\\myUser\\AppData\\Roaming\\npm\\ionic' },
npm ERR!   errno: -4048,
npm ERR!   code: 'EPERM',
npm ERR!   syscall: 'open',
npm ERR!   path: 'C:\\Users\\myUser\\AppData\\Roaming\\npm\\ionic' }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\myUser\AppData\Roaming\npm-cache\_logs\2017-07-27T18_14_32_729Z-debug.log

This is the message I get when I try to run Ionic command after above error:

$ ionic cordova run android
bash: /c/Users/myUser/AppData/Roaming/npm/ionic: No such file or directory

My ID does have administrator rights on this computer.

The only solution I got is to re-install Ionic and all other stuff.

Very frustrating!

Does anybody else get this?

I suggest two things:

  • never run any ionic, cordova, or npm with elevated privileges (sudo or whatever the windows equivalent is)
  • use nvm or nvm-windows to manage your node installations
1 Like

Can you elaborate?

Will check nvm.

Thanks.

In general, you shouldn’t do anything as root that doesn’t absolutely have to be done as root. When it comes to things like npm and ionic that write files all over the place, once you ever run them even once as root, they will likely write things so that you cannot ever run them again as a normal user (hence your EPERM errors). Even worse, you have no easy way of knowing where this has taken place, so it is very difficult to try to clean up the damage.

nvm (and presumably the windows equivalent, although I’ve never used it) keeps all node files in clearly delineated bits of your home directory, so it is trivial to completely clean them up and you never have to run anything as root.

1 Like

Is this related to the update prompt or do you always get this? Doesn’t really seem connected.

Yes, nvm-windows works pretty much the same. Its awesome.

@Sujan12 - I started getting this only after update prompt. It was working fine just before that. :frowning:

And now my whole environment is messed up! Nothing seems to work.

Installed latest node, ionic. Still did not work so deleted my project’s node_modules and ran npm install and now that is also not working. I keep getting:

npm ERR! Cannot read property 'find' of undefined

Any idea what is going wrong?

Following this bug on npm GitHub and trying what people are saying.

Did npm cache verify, didn’t help.

Do you know where is “npm” directory located on Windows 7? Will try deleting it and reinstall Node.

Then do it via nvm-windows: https://github.com/coreybutler/nvm-windows Solves so many problems. npm is usually part of node. Get rid of all of it before you install nvm-windows.

@Sujan12, @rapropos - I am still not sure why I should not be using npm and instead should be using nvm-windows.

I was finally able to resolve my issues except for one which is related to stompjs and perhaps its dependencies. I get the following:

C:\MyApp\node_modules\stompjs\node_modules\websocket>if not defined npm_config_node_gyp (node "C:\Users\myUser\AppData\Roaming\npm\node_modules\npm\bin\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild )  else (node "" rebuild )
gyp ERR! configure error
gyp ERR! stack Error: Can't find Python executable "python", you can set the PYTHON env variable.
gyp ERR! stack     at Object.failNoPython (C:\Users\myUser\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\lib\configure.js:483:19)
gyp ERR! stack     at Object.<anonymous> (C:\Users\myUser\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\lib\configure.js:508:16)
gyp ERR! stack     at C:\Users\myUser\AppData\Roaming\npm\node_modules\npm\node_modules\graceful-fs\polyfills.js:284:29
gyp ERR! stack     at FSReqWrap.oncomplete (fs.js:123:15)
gyp ERR! System Windows_NT 6.1.7601
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\myUser\\AppData\\Roaming\\npm\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd C:\MyApp\node_modules\stompjs\node_modules\websocket
gyp ERR! node -v v6.11.1
gyp ERR! node-gyp -v v3.6.2
gyp ERR! not ok

Followed this node-gyp Github bug to resolve the issue which led me to this link which says that we need to update the node-gyp that’s in Nodejs’s installed directory (C:\Program Files\nodejs\node_modules\npm) but the -g in npm install -g node-gyp@latest goes to different location on Windows 7 (C:\Users\myUser\AppData\Roaming\npm\node_modules\npm\node_modules). It quickly mentions as below but doesn’t give a solution on how I update the node-gyp in my Nodejs folder.

note: i found that the -g on windows 7 is not correct. It gets installed in C:\Users\AppData\Roaming\npm\node_modules\gyp which is not the directory where node is installed C:\Program Files(x86)\nodejs\node_modules\npm\node_modules\node-gyp…

What if I copy it from “C:\Users\myUser\AppData\Roaming\npm\node_modules\npm\node_modules**" to "C:\Program Files\nodejs\node_modules\npm” manually?

This sentence contains type mismatch errors. One thing that helped me understand the ecosystem was reading the Wikipedia articles about NodeJS and npm. I recommend it.

1 Like

:slight_smile: :+1:

Thanks for the pointer. Will definitely check Wikipedia.

I jumped into Ionic/Angular/Node/NPM/TypeScript etc. because of a project and kind of learning things on the job.

I certainly couldn’t have survived without this awesome Ionic Forum! Some seriously great and unbelievably helpful folks!!

Just wanted to put an update here.

I was finally able to resolve the last issue of node-gyp. It was giving that error for ‘stompjs’ library. So, as one of the tries I just deleted the ‘stompjs’ module from my project’s ‘node_modules’ directory and ran npm install again…and wola! :slight_smile:

I think, using npm is not really that bad. I guess right now I just do not have enough knowledge to troubleshoot the issues.

Having said that, I will still check out ‘nvm-windows’.

Node is one thing that brings npm with it when you install it. nvm-windows and nvm are a thing, that enables you to install many nodes (with their own npm) at the same time, in a better way than when you install it standalone as well. You want to have many nodes installed in a good way to have as few problems as possible. Using nvm makes everything better.

1 Like