title: Location and config for local Cordova plugin?
body: <p>I have a standard Cordova project that looks like this:</p>
  
  <pre><code>build.json
  config.xml
  hooks/
  my-custom-plugin/
    src/
    www/
    package.json
    plugin.xml
  package-lock.json
  package.json
  res/
  www/
  </code></pre>
  
  <p>I wrote a custom plugin, which I keep in a subdirectory of the project. I added it to my Cordova project like this:</p>
  
  <pre><code>cordova plugin add my-custom-plugin
  </code></pre>
  
  <p>It added the following to <code>config.xml</code>:</p>
  
  <pre><code>&lt;plugin name="my-custom-plugin" spec="my-custom-plugin" /&gt;
  </code></pre>
  
  <p>and to package.json:</p>
  
  <pre><code>"dependencies": {
      "my-custom-plugin": "file:my-custom-plugin"
  </code></pre>
  
  <p>I prefer not to commit <code>node_modules/</code>, <code>plugins/</code>, or <code>platforms/</code> to SCM; I want to let Cordova recreate those as part of my build process.</p>
  
  <p>But when I check out the above project and run <code>cordova prepare --verbose</code>, it gives me an error:</p>
  
  <pre><code>Failed to restore plugin "my-custom-plugin" from config.xml. You might need to try adding it again. Error: Failed to fetch plugin my-custom-plugin@file:my-custom-plugin via registry.
  Probably this is either a connection problem, or plugin spec is incorrect.
  Check your connection and plugin name/version/URL.
  Error: npm: Command failed with exit code 1 Error output:
  npm ERR! code ENOLOCAL
  npm ERR! Could not install from "my-custom-plugin" as it does not contain a package.json file.
  </code></pre>
  
  <p>(This last message isn't right; as you can see above, it does contain a valid package.json file.)</p>
  
  <p>The detailed error log has:</p>
  
  <pre><code>0 info it worked if it ends with ok
  1 verbose cli [ '/usr/bin/node',
  1 verbose cli   '/usr/bin/npm',
  1 verbose cli   'install',
  1 verbose cli   'my-custom-plugin@file:my-custom-plugin' ]
  2 info using npm@5.6.0
  3 info using node@v8.9.4
  4 verbose npm-session 2b51ee3ccee75e63
  5 silly install loadCurrentTree
  6 silly install readLocalPackageData
  7 silly fetchPackageMetaData error for my-custom-plugin@file:my-custom-plugin Could not install from "my-custom-plugin" as it does not contain a package.json file.
  8 verbose stack Error: ENOENT: no such file or directory, open '/my-project/node_modules/my-custom-plugin/package.json'
  9 verbose cwd /my-project/node_modules
  10 verbose Linux 3.10.0-514.21.1.el7.x86_64
  11 verbose argv "/usr/bin/node" "/usr/bin/npm" "install" "my-custom-plugin@file:my-custom-plugin"
  12 verbose node v8.9.4
  13 verbose npm  v5.6.0
  14 error code ENOLOCAL
  15 error Could not install from "my-custom-plugin" as it does not contain a package.json file.
  16 verbose exit [ 1, true ]
  </code></pre>
  
  <p>If I try running <code>npm install</code> first, that command works, but the <code>cordova prepare</code> command still fails with the same error.</p>
  
  <p>What's the correct way to do this?</p>
  
  <p>I'm using cordova-cli 8.0.0, with node 8.9.4, on both MacOS and Linux.</p>