Closed GuskiS closed 7 years ago
Main file for system.js is in bundles folder https://unpkg.com/ng2-bootstrap@1.1.16-6/bundles/
Imho: drop system.js, it is a crap, try angular-cli It has AoT and really easy to use
@valorkin this issue is still persists
I'm using ng2-bootstrap 1.1.16-9, Angular 2.4.1 and angular-seed which is using systemjs Builder.
My ng2-bootstrap config is
{
name:'ng2-bootstrap',
path:'node_modules/ng2-bootstrap',
packageMeta:{
main: 'bundles/ng2-bootstrap.umd.min.js',
defaultExtension: 'js'
}
}
AoT works fine, however on bundling stage I got similar error as described above:
Message:
Error on fetch for ng2-bootstrap/positioning.js at file:///xxxx/node_modules/ng2-bootstrap/positioning.js
Loading ng2-bootstrap/modal/modal.module.js
Loading dist/tmp/app/app.module.ngfactory.js
Loading dist/tmp/app/main-prod.js
ENOENT: no such file or directory, open 'xxxx/node_modules/ng2-bootstrap/positioning.js'
Details:
originalErr: Error: ENOENT: no such file or directory, open 'xxxx/node_modules/ng2-bootstrap/positioning.js'
Stack:
Error on fetch for ng2-bootstrap/positioning.js at file:///xxxx/node_modules/ng2-bootstrap/positioning.js
Loading ng2-bootstrap/modal/modal.module.js
Loading dist/tmp/app/app.module.ngfactory.js
Loading dist/tmp/app/main-prod.js
Error: ENOENT: no such file or directory, open '/xxxx/node_modules/ng2-bootstrap/positioning.js'
The issue was introduced after 1.1.16
I'm having a similar issue with angular-seed. ng2-bootstrap works with 1.1.15, but if I upgrade to 1.1.16-9 I get an Error on fetch for ng2-bootstrap/accordion.js
error when building the production version (the development one works fine). The relevant section of my project.config.ts
is:
this.SYSTEM_CONFIG_DEV.paths['ng2-bootstrap/ng2-bootstrap'] =
'node_modules/ng2-bootstrap/bundles/ng2-bootstrap.umd.js';
this.SYSTEM_BUILDER_CONFIG.packages['ng2-bootstrap/ng2-bootstrap'] = {
main: 'bundles/ng2-bootstrap.umd.min.js',
defaultExtension: 'js'
};
this.SYSTEM_CONFIG_DEV.paths['moment'] =
'node_modules/moment/moment.js';
this.SYSTEM_BUILDER_CONFIG.packages['moment'] = {
main: 'moment.js',
defaultExtension: 'js'
};
This is a large project which would not be trivial to migrate to angular-cli, so a fix forSystemJS would be nice.
I need a sample Repo to reproduce
Can you please make a PR to https://github.com/valor-software/angular2-quickstart So I can reproduce When done please drop me a note here: https://ngx-slack.herokuapp.com So I can fix this asap
I do have the same issue with SystemJs. When I try to upgrade latest version. Tried with v1.1.16-9 . @valorkin
before upgrade it was 'ng2-bootstrap': { main: '/bundles/ng2-bootstrap.umd.js', defaultExtension: 'js' },
After upgrade I tried with both 'ng2-bootstrap': { main: '/bundles/ng2-bootstrap.umd.js', defaultExtension: 'js' }, or 'ng2-bootstrap': { main: 'main.js', defaultExtension: 'js' },
The error is , Modules are trying to findout accordion.js , modal.js, carousel.js in the root folder. which is not exists any more
I still need a Repo to reproduce, I am not using system.js
This is a repo to reproduce the issue. https://github.com/irsick/ng2-bootstrap-issue-1343 Please see readme for details.
Angular-quickstart doesn't have production bundling routine so it's based on angular2-seed instead.
It seems the issue is somewhere between new ng2-bootstrap structure and systemjs buildStatic() function.
@mgechev can you help me with this issue please?
ok, seems I have found a solution build passed without errors
in project.config.ts I did 2 changes:
moved moment
to libs
// Add `NPM` third-party libraries to be injected/bundled.
this.NPM_DEPENDENCIES = [
...this.NPM_DEPENDENCIES,
{src:'moment/moment.js', inject: 'libs'}
// {src: 'jquery/dist/jquery.min.js', inject: 'libs'},
// {src: 'lodash/lodash.min.js', inject: 'libs'},
];
changed how ng2-bootstrap is registered
let additionalPackages: ExtendPackages[] = [
{
name:'ng2-bootstrap',
path:'ng2-bootstrap',
packageMeta:{
main: 'bundles/ng2-bootstrap.umd.min.js',
defaultExtension: 'js'
}
}
];
this issue with system.js was very helpful https://github.com/InfomediaLtd/angular2-materialize/issues/115#issuecomment-254809673
@binarydigits please try this too, if it doesn't helping please provide Repo to reproduce
@irsick if this will work, please give me a note So I will add note to documentation
@valorkin The solution partially works. It does do bundling for non-AoT build $ npm run build.prod
However it still fails to to find correct paths for AoT build $ npm run build.prod.exp
moment.js format change doesn't effect anything
Here's working configuration:
let additionalPackages: ExtendPackages[] = [
{
name:'ng2-bootstrap',
path:'node_modules/ng2-bootstrap/bundles/ng2-bootstrap.umd.min.js'
},
{
name:'ng2-bootstrap/*',
path:'node_modules/ng2-bootstrap/bundles/ng2-bootstrap.umd.min.js'
},
{
name:'moment',
path:'node_modules/moment',
packageMeta:{
main: 'moment.js',
defaultExtension: 'js'
}
}
];
Happy holidays 🎅 🎄 🎁
@mgechev thanks a lot! :) Happy Holidays to you too :)
I confirm it's working. The asterisk did the trick. I'll add some comments, if you don't mind.
let additionalPackages: ExtendPackages[] = [
// required for dev build
{
name:'ng2-bootstrap',
path:'node_modules/ng2-bootstrap/bundles/ng2-bootstrap.umd.min.js'
},
// required for prod build
{
name:'ng2-bootstrap/*',
path:'node_modules/ng2-bootstrap/bundles/ng2-bootstrap.umd.min.js'
},
// mandatory dependency for ng2-bootstrap datepicker
{
name:'moment',
path:'node_modules/moment',
packageMeta:{
main: 'moment.js',
defaultExtension: 'js'
}
}
];
Thank you both @valorkin and @mgechev. Happy Holidays!
Please update docs to safe time and nerves for a lot of folks.
don't close this issue, so I can add this to docs
documenting full steps to install and test after finding this thread.
npm install --save bootstrap moment ng2-bootstrap
project.config.ts
` //uncomment this import { ExtendPackages } from './seed.config.interfaces';
// Add `NPM` third-party libraries to be injected/bundled.
this.NPM_DEPENDENCIES = [
...this.NPM_DEPENDENCIES,
// {src: 'jquery/dist/jquery.min.js', inject: 'libs'},
// {src: 'lodash/lodash.min.js', inject: 'libs'},
{ src: 'bootstrap/dist/js/bootstrap.min.js', inject: 'libs' },
{ src: 'bootstrap/dist/css/bootstrap.min.css', inject: true }, // inject into css section
{ src: 'bootstrap/dist/css/bootstrap-theme.min.css', inject: true }, // inject into css section
{ src: 'bootstrap/dist/css/bootstrap-theme.min.css.map', inject: true }, // inject into css section
];
*towards the bottom, replace extended packages with this:
let additionalPackages: ExtendPackages[] = [ // required for dev build { name:'ng2-bootstrap', path:'node_modules/ng2-bootstrap/bundles/ng2-bootstrap.umd.min.js' },
// required for prod build
{
name:'ng2-bootstrap/*',
path:'node_modules/ng2-bootstrap/bundles/ng2-bootstrap.umd.min.js'
},
// mandatory dependency for ng2-bootstrap datepicker
{
name:'moment',
path:'node_modules/moment',
packageMeta:{
main: 'moment.js',
defaultExtension: 'js'
}
}
];
this.addPackagesBundles(additionalPackages);
`
verify by adding an alert to the home module and html:
home.module.ts:
`import { AlertModule } from 'ng2-bootstrap/alert';
@NgModule({ imports: [CommonModule, HomeRoutingModule, SharedModule, AlertModule.forRoot()], declarations: [HomeComponent], exports: [HomeComponent], providers: [NameListService] }) import { AlertModule } from 'ng2-bootstrap/alert';`
@NgModule({ imports: [CommonModule, HomeRoutingModule, SharedModule, AlertModule.forRoot()], declarations: [HomeComponent], exports: [HomeComponent], providers: [NameListService] })
home.component.html:
<alert type="success"> <strong>Well done!</strong> You successfully read this important alert message. </alert>
Awesome! Thank you so much :)
At the moment I'm trying to update my packages and I'm having issues with systemjs.
systemjs.config.js
:app.module
:shared.module
:It compiles fine but then in browser console I get:
Where
ng2-bootstrap/positioning.js:2:24
:Any ideas?