title: why package.json script works fine on local project but doesn't work on a dependency project
body: <p>I have created a npm module(let call it <code>ModuleA</code>) and defined <code>clean</code> script in its package.json file like below:</p>
  
  <pre><code>"scripts": {
      "test": "nyc mocha tests/ --opts mocha.opts",
      "build": "babel -d dist/ src/",
      "prepublish": "yarn run clean &amp;&amp; yarn run build",
      "postinstall": "yarn run clean &amp;&amp; yarn run build",
      "clean": "rimraf ./dist"
    },
  </code></pre>
  
  <p>I use <code>rimraf</code> to remove the <code>dist</code> directory. This dependency is defined in <code>devDependencies</code> as <code>"rimraf": "^2.6.1"</code>. It works fine on this project. But in one of my other project (let call it <code>ModuleB</code>) which has a dependency on this module, the <code>yarn install</code> doesn't work and I get below error: </p>
  
  <pre><code>$ rimraf ./dist
  sh: 1: rimraf: not found 
  </code></pre>
  
  <p>this error happens when <code>npm/yarn</code> is building the <code>ModuleB</code>. I have checked that <code>rimraf</code> exist in <code>node_modules/.bin</code> directory in <code>ModuleB</code>. It works fine if I install <code>rimraf</code> globally. I wonder how I can make the npm/yarn to use <code>rimraf</code> from <code>node_modules/.bin/rimraf</code>? </p>
  
  <p>BTW, I also put the <code>rimraf</code> in <code>devDependencies</code> in <code>ModuleB</code>. </p>
  
  <p>I tried to update the script in <code>ModuleA</code> to use <code>rimraf</code> from <code>node_modules/.bin/rimraf</code> as below:</p>
  
  <pre><code>"clean": "node_modules/.bin/rimraf ./dist"
  </code></pre>
  
  <p>it works fine on <code>ModuleA</code>. But I got below error when run <code>yarn install</code> on <code>ModuleB</code>:</p>
  
  <pre><code>$ node_modules/.bin/rimraf ./dist 
  info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
  sh: node_modules/.bin/rimraf: No such file or directory
  error Command failed with exit code 127.
  </code></pre>