question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot find module "." when running universal server

See original GitHub issue

When I followed the Angular Universal: server-side rendering tutorial to start the universal server, I met the error:

Error: Cannot find module "."
    at webpackMissingModule (/home/zhezhu/Documents/fm-frontend-jobs/dist/server.js:164237:82)
    at Object.. (/home/zhezhu/Documents/fm-frontend-jobs/dist/server.js:164237:160)
    at __webpack_require__ (/home/zhezhu/Documents/fm-frontend-jobs/dist/server.js:164176:30)
    at Object../node_modules/@swimlane/ngx-charts/release/common/circle-series.component.js (/home/zhezhu/Documents/fm-frontend-jobs/dist/server.js:168816:59)
    at __webpack_require__ (/home/zhezhu/Documents/fm-frontend-jobs/dist/server.js:164176:30)
    at Object../node_modules/@swimlane/ngx-charts/release/common/circle-series.component.ngfactory.js (/home/zhezhu/Documents/fm-frontend-jobs/dist/server.js:169083:10)
    at __webpack_require__ (/home/zhezhu/Documents/fm-frontend-jobs/dist/server.js:164176:30)
    at Object../node_modules/@swimlane/ngx-charts/release/line-chart/line-chart.component.ngfactory.js (/home/zhezhu/Documents/fm-frontend-jobs/dist/server.js:192065:10)
    at __webpack_require__ (/home/zhezhu/Documents/fm-frontend-jobs/dist/server.js:164176:30)
    at Object../src/app/domains/inspector/dmarc-panel/dmarc-panel.component.ngfactory.js (/home/zhezhu/Documents/fm-frontend-jobs/dist/server.js:208172:11)

I tried to start it without webpack, then there would be another error with ngx-charts:

/home/zhezhu/Documents/fm-frontend-jobs/node_modules/@swimlane/ngx-charts/release/line-chart/line-series.component.js:10
import { Component, Input, ChangeDetectionStrategy } from '@angular/core';
       ^

SyntaxError: Unexpected token {
    at new Script (vm.js:74:7)
    at createScript (vm.js:246:10)
    at Object.runInThisContext (vm.js:298:10)
    at Module._compile (internal/modules/cjs/loader.js:646:28)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:689:10)
    at Module.load (internal/modules/cjs/loader.js:589:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:528:12)
    at Function.Module._load (internal/modules/cjs/loader.js:520:3)
    at Module.require (internal/modules/cjs/loader.js:626:17)
    at require (internal/modules/cjs/helpers.js:20:18)

and I don’t know why.

Thanks for your help.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:16 (9 by maintainers)

github_iconTop GitHub Comments

3reactions
Pibomeistercommented, Sep 25, 2018

@yanivamrami Yes as a matter of fact I did. The issue is with how ngx charts is packaged, currently node doesn’t support the current packaging. To fix this I installed Babbel as a dev dependency and added the following scripts to my package.json:

  • “compile_@swimlane_ngx-charts”: “babel node_modules/@swimlane/ngx-charts -d node_modules/@swimlane/ngx-charts --presets es2015”

  • “postinstall”: “npm run compile_@swimlane_ngx-charts”

So whenever I run npm install, ngx charts is automatically compiled into a compatible format. I have no issues runnning this with Angular 6.1.6, @nguniversal/express-engine 6.1.0 and @nguniversal/common 6.1.0.

Hope I was of help!

2reactions
marjan-georgievcommented, Jul 17, 2018

Merged the PR. This will be in the next release. Thanks for the contribution everyone!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cannot find module 'XXXXXXX/server/main.js' - Stack Overflow
I'm quite new with angular universal. I have a project which runs fine normally. Now I want to use the server side rendering...
Read more >
In package - GitHub
Error : Cannot find module 'require("./server/main")' ... i used 'ng-toolkit/universal' and after running 'npm run server' i got same error.
Read more >
angular/universal - Gitter
Error : Cannot find module 'C:\angular2\angular4universal\dist\server.js' ... Hi i use the branch angular-5 and when run npm run build:dynamic && npm run ...
Read more >
Cannot find module '@angular/core' error | bobbyhadz
To solve the error "Cannot find module '@angular/core'", make sure you have installed all dependencies by running the npm install command, set the...
Read more >
Cannot find module 'react-dom/server' - Rock, Paper, Sitecore
I was working on a new project this week and starting with JSS 20. This wasn't a NextJS project, unfortunately, so it was...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found