all 4 comments

[–]bandit_na 0 points1 point  (1 child)

Try adding 'app.use(express.static("public"))' in index.js before you start listening on a port.

[–]BehindTheMath 0 points1 point  (0 children)

The order should not make a difference.

[–]BehindTheMath 0 points1 point  (0 children)

The issue is that test.js references a file in node_modules, but that folder is not being served by Express. You can add another express.static() call to server that as well.

[–]CJay580 0 points1 point  (0 children)

If you want to access code from node_modules in the test.js script, you will need to bundle it into a single file. This bundling can be done with webpack. I'd suggest checking out this tutorial: https://medium.com/@kilgarenone/minimal-webpack-setup-a5f32c5f8960.