title: Getting 'Uncaught Error: Script error' for a declared dependency when using r.js
body: <p>I couldn't find an answer for my issue on SO or Github, so I am posting this:</p>
  
  <p>I created a repo for this issue: 
  <a href="https://github.com/saviomuc/requireJSMultiPage" rel="nofollow noreferrer">https://github.com/saviomuc/requireJSMultiPage</a></p>
  
  <p>I tried to set up require.js for a multipage project.</p>
  
  <p>All is fine when I am running the page.
  But when I try to optimize the files with r.js I am getting this error:</p>
  
  <pre><code>GET http://localhost:63342/requirejs/www-build/js/library.js 404 (Not Found) require.js:7
  Uncaught Error: Script error for: library
  http://requirejs.org/docs/errors.html#scripterror 
  </code></pre>
  
  <p>The setup is like this:</p>
  
  <pre><code>js/app/app1.js
  js/app/app1jq.js
  js/lib/require.js
  js/lib/library.js
  main-page1.js
  </code></pre>
  
  <p>Currently require.js loads a file (main-page1.js) which contains this code</p>
  
  <pre><code>require(['common','app/app1','app/app1jq'], function (config) {});
  </code></pre>
  
  <p><code>common.js</code> contains</p>
  
  <pre><code>    requirejs.config({
          paths: {
              library: 'lib/library'
          }
      });
      console.log('This is the config!');
  </code></pre>
  
  <p><code>app1jq.js</code> contains </p>
  
  <pre><code>    define(function (require) {
          var library = require('library');
          console.log('This is dependent on library');
      });
  </code></pre>
  
  <p>Could this be an issue with the optimizer? Or did I do something wrong? </p>
  
  <p>Best and thank you in advance!</p>