title: npm install -g ionic cordova - ENOTDIR issue
body: <p>I have a problem with my installation.
  Previous dev left 4 years ago no documentation ... now it falls on me to build the outdated app because marketing wants a new feature.
  I'm into embedded systems so I know almost nothing.</p>
  <p>Onto the configuration : I have made a Dockerfile so that the environment is stable, I'm using Docker Desktop (Windows 10). The end goal is to make it work in Docker and do a full CI/CD but first I need to generate an apk.</p>
  <pre><code># base image
  FROM ubuntu:20.04 
  
  # block interactive actions (ex selecting country during installation)
  ARG DEBIAN_FRONTEND=noninteractive
  
  # install linux packages
  RUN apt-get update &amp;&amp; apt-get -y install wget tar unzip openjdk-8-jdk build-essential checkinstall file apt-utils libreadline-gplv2-dev libncursesw5-dev libssl-dev libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev
  
  # install python 2.7.18 
  RUN mkdir /python2.7 &amp;&amp; cd /python2.7 &amp;&amp; wget https://www.python.org/ftp/python/2.7.18/Python-2.7.18.tgz &amp;&amp; tar xzf Python-2.7.18.tgz &amp;&amp; rm Python-2.7.18.tgz &amp;&amp; cd Python-2.7.18 &amp;&amp; ./configure --enable-optimizations &amp;&amp; make altinstall
  
  # install node js version 10.19.0 for linux
  #RUN wget https://nodejs.org/dist/v10.19.0/node-v10.19.0-linux-x64.tar.gz &amp;&amp; tar -C /usr/local --strip-components 1 -xzf node-v10.19.0-linux-x64.tar.gz &amp;&amp; rm node-v10.19.0-linux-x64.tar.gz
  #RUN wget https://nodejs.org/dist/v12.13.0/node-v12.13.0-linux-x64.tar.gz &amp;&amp; tar -C /usr/local --strip-components 1 -xzf node-v12.13.0-linux-x64.tar.gz &amp;&amp; rm node-v12.13.0-linux-x64.tar.gz
  RUN wget https://nodejs.org/download/release/v7.7.0/node-v7.7.0-linux-x64.tar.gz &amp;&amp; tar -C /usr/local --strip-components 1 -xzf node-v7.7.0-linux-x64.tar.gz &amp;&amp; rm node-v7.7.0-linux-x64.tar.gz
  
  #install gradle 4.10.3 (reinstalling gradle 3.3 during the build ???)
  RUN wget https://services.gradle.org/distributions/gradle-4.10.3-bin.zip -P /tmp &amp;&amp; unzip -d /opt/gradle /tmp/gradle-4.10.3-bin.zip &amp;&amp; rm /tmp/gradle-4.10.3-bin.zip
  
  # install android command line 
  RUN wget https://dl.google.com/android/repository/commandlinetools-linux-7583922_latest.zip &amp;&amp; mkdir -p /sdk &amp;&amp; mv commandlinetools-linux-7583922_latest.zip /sdk &amp;&amp; \
      cd /sdk &amp;&amp; unzip commandlinetools-linux-7583922_latest.zip &amp;&amp; rm commandlinetools-linux-7583922_latest.zip
  WORKDIR &quot;/sdk/cmdline-tools&quot;
  
  # specific to commandlinetools-linux-7583922 the unzipped folder is not correct, it needs to be under &quot;latest&quot; folder, so /cmdline-tools/latest/...
  # see https://stackoverflow.com/a/67413427/14137672 for more informations about this
  RUN mkdir .latest &amp;&amp; mv * .latest &amp;&amp; mv .latest latest
  
  # add sdkmanager java gradle to path platform-tools tools
  ENV PATH=&quot;/sdk/cmdline-tools/latest/bin:/usr/lib/jvm/java-8-openjdk-amd64/bin/:/sdk/cmdline-tools/latest:/opt/gradle/gradle-4.10.3/bin:/python2.7/Python-2.7.18:${PATH}:/sdk/tools/:/sdk/platform-tools/&quot;
  # create env variable ANDROID_SDK_ROOT &amp; GRADLE_HOME
  ENV ANDROID_SDK_ROOT=/sdk/cmdline-tools/latest/bin
  ENV ANDROID_HOME=/sdk/
  ENV GRADLE_HOME=/opt/gradle/gradle-4.10.3
  
  # install project requirements, Android Studio part
  WORKDIR &quot;/sdk/cmdline-tools/latest/bin&quot;
  RUN chmod +770 /sdk/cmdline-tools/latest/bin/sdkmanager
  # accept the licenses BEFORE installing packages else it doesn't install but doesn't launch errors
  RUN yes | /sdk/cmdline-tools/latest/bin/sdkmanager --licenses
  RUN /sdk/cmdline-tools/latest/bin/sdkmanager &quot;platform-tools&quot; &quot;platforms;android-19&quot; &quot;platforms;android-20&quot; &quot;platforms;android-21&quot; &quot;platforms;android-22&quot; &quot;platforms;android-23&quot; &quot;platforms;android-24&quot; &quot;platforms;android-25&quot; &quot;system-images;android-28;default;x86&quot; &quot;system-images;android-27;default;x86&quot;
  RUN /sdk/cmdline-tools/latest/bin/sdkmanager &quot;platforms;android-26&quot; &quot;platforms;android-27&quot; &quot;platforms;android-28&quot; &quot;platforms;android-29&quot; &quot;platforms;android-30&quot; &quot;platforms;android-31&quot; &quot;skiaparser;1&quot; &quot;system-images;android-29;google_apis;x86&quot;
  RUN /sdk/cmdline-tools/latest/bin/sdkmanager &quot;build-tools;31.0.0&quot; &quot;build-tools;30.0.2&quot; &quot;build-tools;29.0.3&quot; &quot;build-tools;29.0.2&quot; &quot;build-tools;29.0.1&quot; &quot;build-tools;29.0.0&quot; &quot;build-tools;28.0.3&quot; &quot;build-tools;20.0.0&quot; &quot;build-tools;19.1.0&quot; &quot;system-images;android-31;default;x86_64&quot;
  RUN /sdk/cmdline-tools/latest/bin/sdkmanager &quot;cmdline-tools;5.0&quot; &quot;cmdline-tools;4.0&quot; &quot;ndk;23.1.7779620&quot; &quot;emulator&quot; &quot;extras;google;market_apk_expansion&quot; &quot;extras;google;instantapps&quot; &quot;extras;google;market_licensing&quot; &quot;extras;google;google_play_services&quot;
  RUN /sdk/cmdline-tools/latest/bin/sdkmanager &quot;system-images;android-19;default;x86&quot; &quot;system-images;android-21;default;x86&quot; &quot;system-images;android-22;default;x86&quot; &quot;system-images;android-23;default;x86&quot; &quot;system-images;android-24;default;x86&quot; &quot;system-images;android-25;default;x86&quot; &quot;system-images;android-26;default;x86&quot; 
  
  
  
  
  # install project dependancies
  RUN npm install &amp;&amp; npm install -g ionic@5.4.16 cordova@10.0.0 native-run@1.5.0 cordova-res --unsafe-perm
  </code></pre>
  <p>So the line where I have a problem is <code>npm install -g ionic</code> where I have an error :</p>
  <pre><code>npm ERR! Linux 5.4.0-124-generic
  npm ERR! argv &quot;/usr/local/bin/node&quot; &quot;/usr/local/bin/npm&quot; &quot;install&quot; &quot;-g&quot; &quot;ionic@5.4.16&quot; &quot;cordova@10.0.0&quot; &quot;native-run@1.5.0&quot; &quot;cordova-res&quot; &quot;--unsafe-perm&quot;
  npm ERR! node v7.7.0
  npm ERR! npm  v4.1.2
  npm ERR! path /usr/local/lib/node_modules/.staging/@types/node-14361f48/package.json
  npm ERR! code ENOTDIR
  npm ERR! errno -20
  npm ERR! syscall open
  
  npm ERR! ENOTDIR: not a directory, open '/usr/local/lib/node_modules/.staging/@types/node-14361f48/package.json'
  npm ERR! 
  npm ERR! If you need help, you may report this error at:
  npm ERR!     &lt;https://github.com/npm/npm/issues&gt;
  
  npm ERR! Please include the following file with any support request:
  npm ERR!     /home/mathieu/Bureau/toto/toto/npm-debug.log
  </code></pre>
  <p>My package.json is :</p>
  <pre><code>{
      &quot;name&quot;: &quot;toto&quot;,
      &quot;version&quot;: &quot;0.0.3&quot;,
      &quot;author&quot;: &quot;Ionic Framework&quot;,
      &quot;homepage&quot;: &quot;http://ionicframework.com/&quot;,
      &quot;private&quot;: true,
      &quot;scripts&quot;: {
          &quot;run-android&quot;: &quot;ionic cordova run android -l -c --device&quot;,
          &quot;start&quot;: &quot;ionic-app-scripts serve&quot;,
          &quot;clean&quot;: &quot;ionic-app-scripts clean&quot;,
          &quot;build&quot;: &quot;ionic-app-scripts build&quot;,
          &quot;lint&quot;: &quot;ionic-app-scripts lint&quot;
      },
      &quot;dependencies&quot;: {
          &quot;@angular/animations&quot;: &quot;5.2.11&quot;,
          &quot;@angular/common&quot;: &quot;5.2.11&quot;,
          &quot;@angular/compiler&quot;: &quot;5.2.11&quot;,
          &quot;@angular/compiler-cli&quot;: &quot;5.2.11&quot;,
          &quot;@angular/core&quot;: &quot;5.2.11&quot;,
          &quot;@angular/forms&quot;: &quot;5.2.11&quot;,
          &quot;@angular/http&quot;: &quot;5.2.11&quot;,
          &quot;@angular/platform-browser&quot;: &quot;5.2.11&quot;,
          &quot;@angular/platform-browser-dynamic&quot;: &quot;5.2.11&quot;,
          &quot;@ionic-native/ble&quot;: &quot;^4.16.0&quot;,
          &quot;@ionic-native/core&quot;: &quot;~4.15.0&quot;,
          &quot;@ionic-native/splash-screen&quot;: &quot;~4.15.0&quot;,
          &quot;@ionic-native/status-bar&quot;: &quot;~4.15.0&quot;,
          &quot;@ionic/storage&quot;: &quot;^2.2.0&quot;,
          &quot;@ngx-translate/core&quot;: &quot;^9.1.1&quot;,
          &quot;@ngx-translate/http-loader&quot;: &quot;^2.0.1&quot;,
          &quot;cordova&quot;: &quot;^6.5.0&quot;,
          &quot;cordova-plugin-ble-central&quot;: &quot;^1.2.2&quot;,
          &quot;cordova-plugin-compat&quot;: &quot;^1.2.0&quot;,
          &quot;cordova-plugin-device&quot;: &quot;^2.0.2&quot;,
          &quot;cordova-plugin-ionic-keyboard&quot;: &quot;^2.1.3&quot;,
          &quot;cordova-plugin-ionic-webview&quot;: &quot;^2.3.3&quot;,
          &quot;cordova-plugin-splashscreen&quot;: &quot;^5.0.2&quot;,
          &quot;cordova-plugin-statusbar&quot;: &quot;^2.4.2&quot;,
          &quot;cordova-plugin-whitelist&quot;: &quot;^1.3.3&quot;,
          &quot;help&quot;: &quot;3.0.2&quot;,
          &quot;ionic-angular&quot;: &quot;3.9.2&quot;,
          &quot;ionicons&quot;: &quot;3.0.0&quot;,
          &quot;rxjs&quot;: &quot;5.5.11&quot;,
          &quot;sw-toolbox&quot;: &quot;3.6.0&quot;,
          &quot;zone.js&quot;: &quot;0.8.26&quot;
      },
      &quot;devDependencies&quot;: {
          &quot;@ionic/app-scripts&quot;: &quot;3.2.0&quot;,
          &quot;BleTotoService&quot;: &quot;file:../ble-toto-service&quot;,
          &quot;cordova-android&quot;: &quot;6.4.0&quot;,
          &quot;typescript&quot;: &quot;~2.6.2&quot;
      },
      &quot;description&quot;: &quot;An Ionic project&quot;,
      &quot;cordova&quot;: {
          &quot;plugins&quot;: {
              &quot;cordova-plugin-ble-central&quot;: {},
              &quot;cordova-plugin-whitelist&quot;: {},
              &quot;cordova-plugin-statusbar&quot;: {},
              &quot;cordova-plugin-device&quot;: {},
              &quot;cordova-plugin-splashscreen&quot;: {},
              &quot;cordova-plugin-ionic-webview&quot;: {
                  &quot;ANDROID_SUPPORT_ANNOTATIONS_VERSION&quot;: &quot;27.+&quot;
              },
              &quot;cordova-plugin-ionic-keyboard&quot;: {},
              &quot;cordova-plugin-ble-toto-service&quot;: {}
          },
          &quot;platforms&quot;: [
              &quot;android&quot;
          ]
      }
  }
  </code></pre>
  <p>Can someone help ? I can't share the sources.</p>
  <p>Edit :
  npm install seems to work now, I went to nodeJS 7.10.0 npm is 4.2.0
  But if I do npm update I have &quot;Cannot read property 'version' of undefined</p>
  <pre><code>385 verbose stack TypeError: Cannot read property 'version' of undefined
  385 verbose stack     at /usr/local/lib/node_modules/npm/lib/outdated.js:360:15
  385 verbose stack     at /usr/local/lib/node_modules/npm/node_modules/read-package-json/read-json.js:356:5
  385 verbose stack     at checkBinReferences_ (/usr/local/lib/node_modules/npm/node_modules/read-package-json/read-json.js:320:45)
  385 verbose stack     at final (/usr/local/lib/node_modules/npm/node_modules/read-package-json/read-json.js:354:3)
  385 verbose stack     at then (/usr/local/lib/node_modules/npm/node_modules/read-package-json/read-json.js:124:5)
  385 verbose stack     at /usr/local/lib/node_modules/npm/node_modules/read-package-json/read-json.js:243:12
  385 verbose stack     at /usr/local/lib/node_modules/npm/node_modules/graceful-fs/graceful-fs.js:78:16
  
  
     385 verbose stack     at tryToString (fs.js:449:3)
      385 verbose stack     at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:436:12)
  386 verbose cwd /usr/local/myapp/toto
      387 error Linux 5.10.16.3-microsoft-standard-WSL2
      388 error argv &quot;/usr/local/bin/node&quot; &quot;/usr/local/bin/npm&quot; &quot;update&quot;
      389 error node v7.10.0
      390 error npm  v4.2.0
      391 error Cannot read property 'version' of undefined
      392 error If you need help, you may report this error at:
      392 error     &lt;https://github.com/npm/npm/issues&gt;
      393 verbose exit [ 1, true ]
  </code></pre>