How to include Cesium in existing Node.js project?

1,224 views
Skip to first unread message

alexande...@gmail.com

unread,
Mar 24, 2016, 11:17:49 AM3/24/16
to cesium-dev
Hello all!

I have Node.js project and I want to include Cesium into it on front-end. I've read https://cesiumjs.org/tutorials/cesium-up-and-running/ and first downloaded archieve http://cesiumjs.org/downloads.html from here. But there a lot of data that is unnecessary for my project. I copied Cesium and CesiumUnminified to my public directory which is available for browser and was able to create a map (tested minified and not minified versions).
My project has next structure http://screencast.com/t/pz49fpLEpwC . "npm install cesium" installs it to node_modules folder which is not available for browser.
How can I allow access to cesium project without copying to public directory?

alexande...@gmail.com

unread,
Mar 25, 2016, 10:18:49 AM3/25/16
to cesium-dev, alexande...@gmail.com
The simples way is to do this:
app.use(express.static(path.join(__dirname, '/node_modules/cesium/Build')));

that was taken from here:
Serve static files from multiple directories, but give precedence to “./public” over the others:

app.use(express.static(__dirname + '/public'));
app.use(express.static(__dirname + '/files'));
app.use(express.static(__dirname + '/uploads'));


http://expressjs.com/en/4x/api.html#app.use

Mark Erikson

unread,
Mar 25, 2016, 1:55:24 PM3/25/16
to cesium-dev, alexande...@gmail.com
Yeah, that's roughly the approach I took in the sample project I just published.  I also did some work to handle bundling with Webpack.  See the link over in https://groups.google.com/forum/#!topic/cesium-dev/Ay7fbqDxyqw for more info.

Mark Erikson

James Fraser

unread,
Feb 26, 2019, 5:42:59 PM2/26/19
to cesium-dev
I build a yeoman generator that integrates cesium into an expressjs app:

Omar Shehata

unread,
Feb 28, 2019, 7:31:18 AM2/28/19
to cesium-dev
Thanks for sharing James! If you haven't already, tweet it at CesiumJS (https://twitter.com/cesiumjs) and I'm sure you'll get a retweet for some extra visibility. 
Reply all
Reply to author
Forward
0 new messages