valor-software / ngx-bootstrap

Fast and reliable Bootstrap widgets in Angular (supports Ivy engine)
https://valor-software.com/ngx-bootstrap
MIT License
5.53k stars 1.69k forks source link

ng2-bootstrap not found install #754

Closed estradamarkie closed 8 years ago

estradamarkie commented 8 years ago

Hi, I've installed ng2-bootstrap using npm install and set up my config like the code below. However when I do that it keep asking me moment.js is not found even though I'm not using momentjs anywhere in my app. I need ng2-bootstrap for the carousel i'm working on, if I don't update the configsystem console.log will say ng2-bootstrap (not found).

System.config({ defaultJSExtensions: true, packages: { app: { format: 'register', defaultExtension: 'js' } }, paths: { 'ng2-bootstrap': 'node_modules/ng2-bootstrap/ng2-bootstrap', } });

valorkin commented 8 years ago

all cool, but ng2-bootstrap uses moment.js for datepicker

valorkin commented 8 years ago

you can check system.js quickstart for configuration details https://github.com/valor-software/angular2-quickstart

estradamarkie commented 8 years ago

Oh so even though you're not using datepicker, momentjs is still required?

Nvm, its all good now thanks Valorkin

valorkin commented 8 years ago

on my opinion it should not, but... for some reason it is

valorkin commented 8 years ago

in worst case I will move datepicker out of bootstrap

quiringk commented 8 years ago

I am using datepicker and have run into this problem. @estradamarkie @valorkin The solution for me is to go into node_modules/ng2-bootstrap/components/datepicker/date-formatter.js and change:

var moment = require('moment');

to

var moment = require('../../../moment/moment');

assuming you have moment.js installed

valorkin commented 8 years ago

this is wrong var moment = require('../../../moment/moment'); webpack? I hope you are using npm 3?

quiringk commented 8 years ago

Yeah 3.10.3. It seems weird that I have to do that. Just yesterday I removed node-modules and reinstalled all of my packages and still had to make that change. Relative code:

var map = {
    'moment':                     'node_modules/moment',
var packages = {
    'moment':                     { defaultExtension: 'js' },
"dependencies": {
    "moment": "2.14.1",
}
{
  "compilerOptions": {
    "target": "es5",
    "module": "commonjs",
    "moduleResolution": "node",
    "sourceMap": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "removeComments": false,
    "noImplicitAny": false
  },
  "exclude": [
    "typings/browser.d.ts",
    "typings/browser",
    "node_modules"
  ]
}
<!-- 2. Configure SystemJS -->
    <script src="systemjs.config.js"></script>
    <script>
      System.import('app').catch(function(err){ console.error(err); });
    </script>
valorkin commented 8 years ago

@quiringk this should help https://github.com/valor-software/angular2-quickstart/blob/master/systemjs.config.js#L8

quiringk commented 8 years ago

Yeah that did it, thanks