title: What is the correct way to add a NPM package to a Laravel 9 project with Laravel Mix?
body: <p><a href="https://laravel-mix.com" rel="nofollow noreferrer">Laravel Mix</a> introduces itself as</p>
  <blockquote>
  <p>An elegant wrapper around Webpack for the 80% use case.</p>
  </blockquote>
  <p>I believe I have a widespread use case, and I want to know if the 80% covers this and how to do it right. It could be any other package, but I have <a href="https://github.com/pandao/editor.md" rel="nofollow noreferrer">editor.md</a> as an example. They want you to install it with <code>npm i editor.md</code> and use it like the following.</p>
  <pre><code>&lt;link rel=&quot;stylesheet&quot; href=&quot;editor.md/css/editormd.min.css&quot; /&gt;
  &lt;div id=&quot;editor&quot;&gt;
      &lt;!-- Tips: Editor.md can auto append a `&lt;textarea&gt;` tag --&gt;
      &lt;textarea style=&quot;display:none;&quot;&gt;### Hello Editor.md !&lt;/textarea&gt;
  &lt;/div&gt;
  &lt;script src=&quot;jquery.min.js&quot;&gt;&lt;/script&gt;
  &lt;script src=&quot;editor.md/editormd.min.js&quot;&gt;&lt;/script&gt;
  &lt;script type=&quot;text/javascript&quot;&gt;
      $(function() {
          var editor = editormd(&quot;editor&quot;, {
              // width: &quot;100%&quot;,
              // height: &quot;100%&quot;,
              // markdown: &quot;xxxx&quot;,     // dynamic set Markdown text
              path : &quot;editor.md/lib/&quot;  // Autoload modules mode, codemirror, marked... dependents libs path
          });
      });
  &lt;/script&gt;
  </code></pre>
  <p>Now I want to know how to get the following paths right.</p>
  <ol>
  <li>editor.md/css/editormd.min.css</li>
  <li>jquery.min.js (not a dependency)</li>
  <li>editor.md/editormd.min.js</li>
  <li>editor.md/lib/</li>
  </ol>
  <p>My ideas/questions:</p>
  <p>I could copy the CSS and JS files with Mix.</p>
  <pre><code>mix.copy(&quot;node_modules/editor.md/css/editormd.min.css&quot;, &quot;public/css/editormd.min.css&quot;);
  mix.copy(&quot;node_modules/editor.md/editormd.min.js&quot;, &quot;public/js/editormd.min.js&quot;);
  </code></pre>
  <p>But then I miss all the files from the lib folder (<em>4th path</em>). I could copy this folder as well. I could copy the entire <code>node_modules/editor.md</code> folder to my assets folder, but this feels too much. And finally, where is jQuery coming from? Do I add it from a CDN? Do I install the npm package? Again, I saw solutions requiring everything in the <code>app.js</code> file.</p>
  <p>How to do it the right way?</p>