1

I have a very simple webpage that uses the lodash library. The reference is a relative path using the node_modules folder.

<script src="node_modules/lodash/lodash.min.js"></script>

I'm also using the http-server package to serve my webpage.

Is there a better way to reference lodash and any libraries I install through NPM besides the relative path through the node_modules folder?

Halcyon
  • 14,631
  • 17
  • 68
  • 99
  • 1
    you could check ES6 modules. It is the recommended approach; however, keep in mind that it might require many changes, as you would be writing all your scripts as modules that can be exported/imported. And you might need to use tools such as Babel or Webpack to help you support those features if the browser does not support them or if the libraries installed do not support them either – Gonzalo.- Apr 09 '19 at 19:27
  • Maybe this helps: https://stackoverflow.com/a/52558858/3634032 – Sam Herrmann Apr 09 '19 at 19:29

0 Answers0