How to use *require.js* to load another library inside p5


I’d like to use the ‘require.js’ library in p5.js to load another library, say ‘fast-csv’

I’ve done locally:

  1. npm install fast-csv
  2. modify the index.html to include the ‘require’:

<script src=“”></script>

  1. In the ‘sketch.js’ code:

var csv = require(’./node_modules/fast-csv’);

But I’m getting error:

Uncaught Error: Module name “node_modules/fast-csv” has not been loaded yet for context: _. Use require([])
at makeError (require.min.js:1)
at Object.s [as require] (require.min.js:1)
at requirejs (require.min.js:1)
at sketch.js:20

Could you help? Thanks a lot.



Welcome to the community!

Your question is not really related to p5js but rather to require.js.

As mentioned in the error you got, you should check this link :

and also :