I have just started working with angular-cesium
and am following their getting started guide for setting up with the angular CLI. On attempting to serve my application, I am am encountering the follow error:
ERROR in ./node_modules/cesium/index.js 9:4
Module parse failed: 'return' outside of function (9:4)
You may need an appropriate loader to handle this file type.
| if (process.env.NODE_ENV === 'production') {
| module.exports = require(path.join(__dirname, 'Build/Cesium/Cesium'));
> return;
| }
|
The contents of the index.js
file for cesium is:
'use strict';
var path = require('path');
// If in 'production' mode, use the combined/minified/optimized version of Cesium
if (process.env.NODE_ENV === 'production') {
module.exports = require(path.join(__dirname, 'Build/Cesium/Cesium'));
return;
}
// Otherwise, use un-optimized requirejs modules for improved error checking. For example 'development' mode
var requirejs = require('requirejs');
requirejs.config({
paths: {
'Cesium': path.join(__dirname, 'Source')
},
nodeRequire: require
});
module.exports = requirejs('Cesium/Cesium');
I can't see where there is a return
outside of a function as per the error I am getting.
What could be going on here to explain the reason behind this error?
I have sample repo here, where this error can be replicated -> https://github.com/parky128/cesium-playground
Thanks
In your tsconfig.json, add a line in your paths section:
"cesium": ["node_modules/cesium/Build/Cesium/Cesium.js"]
This will tell it to look at the 'correct' cesium file instead of the one that is expecting to be ran directing from node (from my understanding)
Note: You could also point to the Build/CesiumUnminified if you prefer