Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: express is not a function #1162

Closed
joterr opened this issue May 7, 2019 · 2 comments
Closed

TypeError: express is not a function #1162

joterr opened this issue May 7, 2019 · 2 comments

Comments

@joterr
Copy link

joterr commented May 7, 2019

Bug Report

What is the expected behavior?

Node can start the Express server with node dist/server

What is the current behavior?

`> node dist/server

/Users/jrulitschka/Documents/_/Training/2018/FLF.ME/git/frontend-spa/dist/server.js:117
var app = express();
^

TypeError: express is not a function
at Object. (/Users/jrulitschka/Documents//Training/2018/FLF.ME/git/frontend-spa/dist/server.js:117:11)
at webpack_require (/Users/jrulitschka/Documents/
/Training/2018/FLF.ME/git/frontend-spa/dist/server.js:20:30)
at result (/Users/jrulitschka/Documents//Training/2018/FLF.ME/git/frontend-spa/dist/server.js:84:18)
at Object. (/Users/jrulitschka/Documents/
/Training/2018/FLF.ME/git/frontend-spa/dist/server.js:87:10)
at Module._compile (module.js:653:30)
at Object.Module._extensions..js (module.js:664:10)
at Module.load (module.js:566:32)
at tryModuleLoad (module.js:506:12)
at Function.Module._load (module.js:498:3)
at Function.Module.runMain (module.js:694:10)`

And in file server.js there is a different structure than in my project, see:
Object.defineProperty(exports, "__esModule", { value: true }); __webpack_require__(1); var core_1 = __webpack_require__(6); // Express Engine var express_engine_1 = __webpack_require__(206); // Import module map for lazy loading var module_map_ngfactory_loader_1 = __webpack_require__(277); var express = __importStar(__webpack_require__(278)); var path_1 = __webpack_require__(285); // Faster server renders w/ Prod mode (dev mode never needed) core_1.enableProdMode(); // Express server var app = express();

What modules are related to this issue?

- [ ] aspnetcore-engine
- [ ] common
- [x ] express-engine
- [ ] hapi-engine
- [ ] module-map-ngfactory-loader

Minimal reproduction with instructions:

I've just added Angular Universial via angular CLI ng add @nguniversal/express-engine --clientProject [name] to an existing project. The file server.js (but not the server.ts!) looks different to a new Angular project with SSR.

What is the use-case or motivation for changing an existing behavior?

Environment:

@nguniversal versions

  • aspnetcore-engine:
  • common: ^7.2.6
  • express-engine: ^7.1.1
  • hapi-engine:
  • module-map-ngfactory-loader: ^7.1.1
Angular CLI: 7.3.8
Node: 10.15.3
OS: darwin x64
Angular: 7.2.14
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, platform-server, router

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.13.8
@angular-devkit/build-angular     0.13.8
@angular-devkit/build-optimizer   0.13.8
@angular-devkit/build-webpack     0.13.8
@angular-devkit/core              7.3.8
@angular-devkit/schematics        7.3.8
@angular/cli                      7.3.8
@ngtools/webpack                  7.3.8
@schematics/angular               7.3.8
@schematics/update                0.13.8
rxjs                              6.5.1
typescript                        3.2.4
webpack                           4.29.0

Is there anything else we should know?

@joterr
Copy link
Author

joterr commented May 7, 2019

I think I've got a solution - the bug was related to lodash.

I used "esModuleInterop": true in my tsconfig file to import selected methods of lodash in order to minimize asset size.

After removing this line in my tsconfig everything was fine.

@joterr joterr closed this as completed May 7, 2019
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 4, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant