title: Heroku node_modules not cached
body: <p>I have toplevel package.json where I set cacheDirectories as per <a href="https://devcenter.heroku.com/articles/nodejs-support#custom-caching" rel="nofollow noreferrer">https://devcenter.heroku.com/articles/nodejs-support#custom-caching</a></p>
  
  <pre><code>"scripts": {
      "start": "npm --prefix frontend start &amp;&amp; npm --prefix mockserver start",
  },
  "dependencies": {
  },
  "devDependencies": {
  },
  "cacheDirectories": ["frontend/node_modules", "mockserver/node_modules"],
  ...
  </code></pre>
  
  <p>So no dependencies in toplevel, but I have frontend/package.json and mockserver/package.json with a lot of dependencies that get installed in their respective node_modules. This is how the respective package.jsons look like (for example mockserver):</p>
  
  <pre><code>"scripts": {
      "start": "npm install &amp;&amp; npm run build &amp;&amp; node dist/server.js",
   },
   dependencies...
   devdependencies...
  </code></pre>
  
  <p>This works fine and deploys, but it does not cache the the two node_modules defined to be cached.</p>
  
  <p>Here is the output from heroku build:</p>
  
  <pre><code>-----&gt; Creating runtime environment
  
         NPM_CONFIG_LOGLEVEL=error
         NPM_CONFIG_PRODUCTION=true
         NODE_VERBOSE=false
         NODE_ENV=demo
         NODE_MODULES_CACHE=true
  
         npm scripts will see NODE_ENV=production (not 'demo')
         https://docs.npmjs.com/misc/config#production
  -----&gt; Installing binaries
         engines.node (package.json):  7.10.0
         engines.npm (package.json):   unspecified (use default)
  
         Downloading and installing node 7.10.0...
         Using default npm version: 4.2.0
  -----&gt; Restoring cache
         Loading 2 from cacheDirectories (package.json):
         - frontend/node_modules (not cached - skipping)
         - mockserver/node_modules (not cached - skipping)
  -----&gt; Building dependencies
         Installing node modules (package.json)
  -----&gt; Caching build
         Clearing previous node cache
         Saving 2 cacheDirectories (package.json):
         - frontend/node_modules (nothing to cache)
         - mockserver/node_modules (nothing to cache)
  -----&gt; Build succeeded!
  </code></pre>
  
  <p>Just to note that the two node_modules were installed in the previous build but it says (not cached - skipping).</p>
  
  <p>Thanks in advance!</p>