title: npm install modules throwing an ENOENT error within local project inside vagrant box
body: <p>For some reason <em>I am getting an <strong>ENOENT error</strong> on <strong>most</strong> (but not all) modules that I try to install <strong>locally</strong>.</em></p>
  
  <p>All NPM install functions work - without SUDO (which is important on this system) - if I am in the root/global folder (home/vagrant/).</p>
  
  <pre><code>$ nvm --version
  0.35.3
  $ npm -version
  6.14.4
  $ node -v
  v13.12.0
  $ which npm
  /home/vagrant/.nvm/versions/node/v13.12.0/bin/npm
  </code></pre>
  
  <p>But I have a local node project in /var/www/html/node/</p>
  
  <p>Most NPM packages throw an ENOENT error when I try to install them but some seem to work: I can't work out why!</p>
  
  <p>The following Work (and update the local package.json):</p>
  
  <pre><code>npm install underscore
  npm install debug
  npm install chokidar
  </code></pre>
  
  <p>But the far more important modules below all throw a variation of the same error (with or without sudo): </p>
  
  <p><code>npm install express</code>
  <code>npm install webpack</code>
  <code>npm install http-server</code>
  <code>npm install npm-check-updates</code>
  (and many others)</p>
  
  <p>I can still node app.js within this folder if my script doesn't call any of these but as soon as I 'require' a modules that can't be installed it falls over.</p>
  
  <p>The error I get on <code>npm install [module]</code> (with or without sudo, -g or --save/--save-dev) is a version of the following:</p>
  
  <pre><code>npm WARN node@1.0.0 No description
  npm WARN node@1.0.0 No repository field.
  
  npm ERR! code ENOENT
  npm ERR! syscall open
  npm ERR! path /var/www/html/node/node_modules/send/node_modules/debug/node_modules/ms/package.json.3354100157
  npm ERR! errno -2
  npm ERR! enoent ENOENT: no such file or directory, open '/var/www/html/node/node_modules/send/node_modules/debug/node_modules/ms/package.json.3354100157'
  npm ERR! enoent This is related to npm not being able to find a file.
  npm ERR! enoent 
  
  npm ERR! A complete log of this run can be found in:
  npm ERR!     /home/vagrant/.npm/_logs/2020-04-11T11_00_48_913Z-debug.log
  </code></pre>
  
  <p>I have tried: 
   - Destroying my vagrant box and reinstalling it
   - reinstalling npm, node and nvm (a few times - which apparently seems to work but there are lots of 'red' depreciated warnings)
   - NPM cache-clean, npm prune, npm cache-clean -force, npm clean-install
   - deleting package-lock.json (and package.json) before each npm install 
   - Amending the 'global' install location within the global npm install through the below - however, this gives me a <code>nvm is not compatible with the npm config "prefix" option</code> error that insists I reset the prefix back to default. </p>
  
  <pre><code>    # Set global npm package install to a location that doesn't require sudo
      cd ~ &amp;&amp; mkdir .node_modules_global
      npm config set prefix=$HOME/.node_modules_global
  
      # Now secondarily install npm in the new global location
      npm install npm@latest -g
  
      # Add the global npm folder to the path directory
      export PATH="$HOME/.node_modules_global/bin:$PATH"
      source ~/.bashrc
  </code></pre>
  
  <p>The error for the other modules is identical to the one copied above other than different paths (to /var/www/html/node/node_modules/assert/node_modules/util/<em>, /var/www/html/node/node_modules/follow-redirects/node_modules/debug/</em> and /var/www/html/node/node_modules/ansi-align/node_modules/strip-ansi*).  My node_modules folder doesn't contain these subfolders but I can't work out why NPM install won't add them!</p>