I have a skeleton application build with mgechev/angular-seed
and 2muchcoffeecom/ngx-restangular
. I would like to integrate them but I cannot find out the solution how to do it.
Before I successfully add few packages to project.config.ts
simply following angular-seed
documentation.
Here is a piece of configuration that works fine:
...
# tools/config/project.config.ts
let additionalPackages: ExtendPackages[];
additionalPackages = [ {
name: 'angular2-jwt',
path: 'node_modules/angular2-jwt',
packageMeta: {
defaultExtension: 'js',
}
}, {
name: 'ngx-progressbar',
path: 'node_modules/ngx-progressbar/bundles/ngx-progressbar.umd.js',
}, {
name: 'ng2-charts',
path: 'node_modules/ng2-charts/bundles/ng2-charts.umd.min.js'
}, {
name:'ngx-bootstrap',
path:'node_modules/ngx-bootstrap/bundles/ngx-bootstrap.umd.min.js'
}, {
name:'ngx-bootstrap/*',
path:'node_modules/ngx-bootstrap/bundles/ngx-bootstrap.umd.min.js'
}, {
name:'ng2-select-compat',
path:'node_modules/ng2-select-compat/bundles/ng2-select-compat.umd.min.js'
}, {
name:'ngx-avatar',
path:'node_modules/ngx-avatar/ngx-avatar.umd.js'
}];
...
But when I'm trying to add ngx-restangular
:
...
# tools/config/project.config.ts
const additionalPackages: ExtendPackages[] = [
{
name: 'ngx-restangular',
path: 'node_modules/ngx-restangular/dist/esm/src/',
packageMeta: {
defaultExtension: 'js',
main: './index.js',
}
}];
...
Application throws an error:
(index):60 SyntaxError: Unexpected token < at eval (<anonymous>)
In the browser network tab I can see that ngx-restangular
files are loading:
Link to Github repository. To run it in your local env, please simply clone/fork and npm install && npm start
Link configuration file project.config.ts
From looking at this:
Error: SyntaxError: Unexpected token <
It seems its trying to parse a html 404 response. Its quite possible its trying to access a file that it cannot locate. I see you are using .umd.js. Is this correctly configured within your config file? Something like this:
additionalPackages.forEach(function (pkgName) {
packages['@angular/' + pkgName] = { main: 'bundle/'+ pkgName + '.umd.js', defaultExtension: 'js' };
}
The link i passed in here maybe of some help also. Hope this helps!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With