Ben Winding
Ben Winding

Reputation: 11787

Node npm - referencing three.js module on the front end

I'm currently using the node npm to manage dependencies like jquery on the front end. Using the following method.

Server (working)

app.use('/jquery', express.static(__dirname + '/node_modules/jquery/dist/'));

Client (working)

<script src="/jquery/jquery.js"></script>

This works, but I was hoping to be able to manage the dependency 'three.js' from the server side too. Something like...

Server (not working)

app.use('/three', express.static(__dirname + '/node_modules/three/dist/'));

Client (not working)

<script src="/three/three.js"></script>

Error ()

failed to load resource the server responded with a status of 404 (not found)

How can I find the directory structure of the npm module?

Upvotes: 1

Views: 362

Answers (1)

balinthaller
balinthaller

Reputation: 38

In the three.js project, the built files are located in the build directory, not the dist.

On the server, this should work:

app.use('/three', express.static(__dirname + '/node_modules/three/build/'));

Upvotes: 1

Related Questions