akveo / nebular

:boom: Customizable Angular UI Library based on Eva Design System :new_moon_with_face::sparkles:Dark Mode
https://akveo.github.io/nebular
MIT License
8.05k stars 1.51k forks source link

Build error "Can't resolve" while Serve works #1374

Closed orpuig closed 5 years ago

orpuig commented 5 years ago

Issue type

I'm submitting a ...

Issue description

Current behavior:

When building (ng build -c prod) with producion flags (see below) we get many errors, all of the same kind (see also below). We also get many warnings.

The compilation spends unusual amount of time building modules, chunking... 79% chunk modules optimization ModuleConcatenationPlugin ...and on many chunk asset optimization.

It started when updating to Nebular 3.4.2 from 3.1.0. When serving (ng server) everything works smoothly.

Output errors:

ERROR in ./node_modules/@nebular/theme/components/calendar-kit/components/calendar-day-picker/calendar-day-cell.component.js
Module not found: Error: Can't resolve '../../services/date-time-util' in '/home/user/EsplacNeXt/node_modules/@nebular/theme/components/calendar-kit/components/calendar-day-picker'
ERROR in ./node_modules/@nebular/theme/components/context-menu/context-menu.directive.js
Module not found: Error: Can't resolve '../popover/helpers/adjustment.helper' in '/home/user/EsplacNeXt/node_modules/@nebular/theme/components/context-menu'
ERROR in ./node_modules/@nebular/theme/components/context-menu/context-menu.directive.js
Module not found: Error: Can't resolve '../popover/helpers/model' in '/home/user/EsplacNeXt/node_modules/@nebular/theme/components/context-menu'
ERROR in ./node_modules/@nebular/theme/components/context-menu/context-menu.directive.js
Module not found: Error: Can't resolve '../popover/helpers/placement.helper' in '/home/user/EsplacNeXt/node_modules/@nebular/theme/components/context-menu'
ERROR in ./node_modules/@nebular/theme/components/context-menu/context-menu.directive.js
Module not found: Error: Can't resolve '../popover/helpers/positioning.helper' in '/home/user/EsplacNeXt/node_modules/@nebular/theme/components/context-menu'
ERROR in ./node_modules/@nebular/theme/components/context-menu/context-menu.directive.js
Module not found: Error: Can't resolve '../popover/helpers/trigger.helper' in '/home/user/EsplacNeXt/node_modules/@nebular/theme/components/context-menu'
ERROR in ./node_modules/@nebular/theme/components/calendar-kit/components/index.js
Module not found: Error: Can't resolve './calendar-date/calendar-date.pipe' in '/home/user/EsplacNeXt/node_modules/@nebular/theme/components/calendar-kit/components'
ERROR in ./node_modules/@nebular/theme/components/calendar-kit/services/calendar-month-model.service.js
Module not found: Error: Can't resolve './date-time-util' in '/home/user/EsplacNeXt/node_modules/@nebular/theme/components/calendar-kit/services'
ERROR in ./node_modules/@nebular/theme/components/calendar-kit/services/index.js
Module not found: Error: Can't resolve './date-time-util' in '/home/user/EsplacNeXt/node_modules/@nebular/theme/components/calendar-kit/services'
ERROR in ./node_modules/@nebular/theme/components/popover/popover.module.js
Module not found: Error: Can't resolve './helpers/adjustment.helper' in '/home/user/EsplacNeXt/node_modules/@nebular/theme/components/popover'
ERROR in ./node_modules/@nebular/theme/components/popover/popover.directive.js
Module not found: Error: Can't resolve './helpers/adjustment.helper' in '/home/user/EsplacNeXt/node_modules/@nebular/theme/components/popover'
ERROR in ./node_modules/@nebular/theme/components/popover/popover.component.js
Module not found: Error: Can't resolve './helpers/model' in '/home/user/EsplacNeXt/node_modules/@nebular/theme/components/popover'
ERROR in ./node_modules/@nebular/theme/components/popover/popover.directive.js
Module not found: Error: Can't resolve './helpers/model' in '/home/user/EsplacNeXt/node_modules/@nebular/theme/components/popover'
ERROR in ./node_modules/@nebular/theme/components/popover/popover.directive.js
Module not found: Error: Can't resolve './helpers/placement.helper' in '/home/user/EsplacNeXt/node_modules/@nebular/theme/components/popover'
ERROR in ./node_modules/@nebular/theme/components/popover/popover.module.js
Module not found: Error: Can't resolve './helpers/placement.helper' in '/home/user/EsplacNeXt/node_modules/@nebular/theme/components/popover'
ERROR in ./node_modules/@nebular/theme/components/popover/popover.directive.js
Module not found: Error: Can't resolve './helpers/positioning.helper' in '/home/user/EsplacNeXt/node_modules/@nebular/theme/components/popover'
ERROR in ./node_modules/@nebular/theme/components/popover/popover.module.js
Module not found: Error: Can't resolve './helpers/positioning.helper' in '/home/user/EsplacNeXt/node_modules/@nebular/theme/components/popover'
ERROR in ./node_modules/@nebular/theme/components/popover/popover.module.js
Module not found: Error: Can't resolve './helpers/trigger.helper' in '/home/user/EsplacNeXt/node_modules/@nebular/theme/components/popover'
ERROR in ./node_modules/@nebular/theme/components/popover/popover.directive.js
Module not found: Error: Can't resolve './helpers/trigger.helper' in '/home/user/EsplacNeXt/node_modules/@nebular/theme/components/popover'
ERROR in ./node_modules/@nebular/theme/components/calendar-kit/services/index.js
Module not found: Error: Can't resolve './locale.service' in '/home/user/EsplacNeXt/node_modules/@nebular/theme/components/calendar-kit/services'
ERROR in ./node_modules/@nebular/theme/components/calendar-kit/services/calendar-month-model.service.js
Module not found: Error: Can't resolve './locale.service' in '/home/user/EsplacNeXt/node_modules/@nebular/theme/components/calendar-kit/services'

Build configuration in angular.json:

"configurations": {
            "prod": {
              "optimization": true,
              "outputHashing": "all",
              "sourceMap": false,
              "extractCss": true,
              "namedChunks": false,
              "aot": true,
              "extractLicenses": true,
              "vendorChunk": false,
              "buildOptimizer": true,
              "fileReplacements": [
                {
                  "replace": "src/environments/environment.ts",
                  "with": "src/environments/environment.prod.ts"
                }
              ]
            },

In case it may be useful, we receive many warning of this kind: "export 'NbTriggerStrategyBuilderService' (imported as 'i8') was not found in '@nebular/theme/components/cdk/overlay/overlay-trigger'

Expected behavior:

Building without errors.

Steps to reproduce:

Not sure there is an easy way to do so.

Other information:

npm, node, OS

npm 5.6.0
node v8.11.2
OS: Linux/Ubuntu

npm list

esplacnext@1.4.0 /home/user/EsplacNeXt
├── @agm/core@1.0.0-beta.5
├── @angular-devkit/build-angular@0.6.8
├── @angular-devkit/core@0.7.0-rc.0
├── @angular-devkit/schematics@0.7.0-rc.0
├── @angular/animations@7.2.6
├── @angular/cdk@7.2.1
├── @angular/cli@7.3.3
├── UNMET PEER DEPENDENCY @angular/common@7.2.6
├── UNMET PEER DEPENDENCY @angular/compiler@7.2.6
├── @angular/compiler-cli@7.2.6
├── UNMET PEER DEPENDENCY @angular/core@7.2.6
├── UNMET PEER DEPENDENCY @angular/forms@7.2.6
├── @angular/http@7.2.6
├── @angular/language-service@7.2.6
├── UNMET PEER DEPENDENCY @angular/platform-browser@7.2.6
├── UNMET PEER DEPENDENCY @angular/platform-browser-dynamic@7.2.6
├── @angular/router@7.2.6
├── @asymmetrik/ngx-leaflet@3.0.1
├── @compodoc/compodoc@1.0.1
├── @nebular/auth@3.4.2
├── @nebular/bootstrap@3.4.2
├── @nebular/security@3.4.2
├── @nebular/theme@3.4.2
├── @ng-bootstrap/ng-bootstrap@4.0.4
├── @sentry/browser@4.4.2
├── @sentry/node@4.4.1
├── @swimlane/ngx-charts@10.1.0
├── @types/d3-color@1.0.5
├── @types/file-saver@2.0.0
├── @types/googlemaps@3.30.4
├── @types/jasmine@2.5.54
├── @types/jasminewd2@2.0.3
├── @types/json2csv@4.2.0
├── @types/leaflet@1.2.3
├── @types/node@6.0.90
├── angular2-chartjs@0.4.1
├── angular2-toaster@6.1.0
├── async@2.6.1
├── bcrypt@2.0.1
├── body-parser@1.18.3
├── boom@7.2.0
├── bootstrap@4.0.0
├── chart.js@2.7.2
├── ckeditor@4.7.3
├── classlist.js@1.1.20150312
├── codelyzer@4.0.2
├── conventional-changelog-cli@1.3.4
├── core-js@2.5.7
├── UNMET PEER DEPENDENCY d3@4.8.0
├── dayjs@1.7.2
├── echarts@4.1.0
├── express@4.16.3
├── file-saver@2.0.1
├── font-awesome@4.7.0
├── getstream@3.18.0
├── husky@0.13.3
├── ibantools@2.0.0
├── intl@1.2.5
├── ionicons@2.0.1
├── jasmine-core@2.6.4
├── jasmine-spec-reporter@4.1.1
├── jquery@1.12.4
├── json2csv@4.3.4
├── jsonwebtoken@8.3.0
├── karma@1.7.1
├── karma-chrome-launcher@2.1.1
├── karma-cli@1.0.1
├── karma-coverage-istanbul-reporter@1.4.3
├── karma-jasmine@1.1.2
├── karma-jasmine-html-reporter@0.2.2
├── leaflet@1.0.3
├── lodash@4.17.10
├── mailgun-js@0.20.0
├── moment@2.22.2
├── mongodb@3.1.1
├── mongoose@5.4.10
├── multer@1.3.1
├── nebular-icons@1.1.0
├── ng-bootstrap@1.6.3
├── ng2-ckeditor@1.2.1
├── ng2-smart-table@1.2.2
├── ng2-tree@2.0.0-rc.4
├── ngx-echarts@2.0.1
├── node@8.11.3
├── node-html-parser@1.1.10
├── node-sass@4.9.2
├── nodejs@0.0.0
├── nodemailer@4.6.7
├── nodemon@1.17.5
├── normalize.css@6.0.0
├── npm-run-all@4.0.2
├── pace-js@1.0.2
├── papaparse@4.6.2
├── passport@0.4.0
├── passport-jwt@3.0.1
├── pdfkit@0.8.3
├── popper.js@1.14.3
├── protractor@5.3.2
├── rimraf@2.6.1
├── roboto-fontface@0.8.0
├── rxjs@6.4.0
├── rxjs-compat@6.3.0
├── socicon@3.0.5
├── stylelint@7.13.0
├── tether@1.4.0
├── tinymce@4.5.7
├── ts-node@3.2.2
├── tslint@5.7.0
├── tslint-language-service@0.9.9
├── typeface-exo@0.0.22
├── UNMET PEER DEPENDENCY typescript@3.1.3
├── web-animations-js@2.2.5
├── winston@3.1.0
├── xlsx@0.13.2
├── xml2js@0.4.19
└── zone.js@0.8.26
orpuig commented 5 years ago

Any clue on this?

pmadhavan commented 5 years ago

I had the similar error while building for prod and it was because of corrupted @angular/cdk package. Since you already have the @angular/cdk included

  1. Check if it is installed without an error by running angular versions cmd ng --version
  2. Check the node_modules/@angular folder for any other corrupted packages. In my case it had a '.cdk/modules' folder and ng --version cmd showed error on it. In that case, delete the node_modules rm -rf node_modules and run fresh npm install. The build for prod worked as expected!
nnixaa commented 5 years ago

This seems to be the cause.