Universal: module.exports = ./../... @ dist/server.js throws Unexpected token .

Created on 21 Jun 2018  路  6Comments  路  Source: angular/universal

Bug Report

What is the expected behavior?

/dist/server.js run without errors.

What is the current behavior?

Throws error "SyntaxError: Unexpected token ." on this generated row:

module.exports = ./../../frontend/website/node_modules/webpack/buildin/module.js;

What modules are related to this issue?

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

Minimal reproduction with instructions:

I can't reproduce the error from e.g. universal-starter. The same line doesn't get generated from there :(

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

See comments in last question.

Environment:

@nguniversal versions

  • express-engine: 6.0.0
  • module-map-ngfactory-loader: 6.0.0
Angular CLI: 6.0.8
Node: 8.10.0
OS: darwin x64
Angular: 6.0.5
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, platform-server, router

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.6.8
@angular-devkit/build-angular     0.6.8
@angular-devkit/build-optimizer   0.6.8
@angular-devkit/core              0.6.8
@angular-devkit/schematics        0.6.8
@angular/cdk                      6.0.0
@angular/cli                      6.0.8
@angular/material                 6.0.0
@ngtools/webpack                  6.0.8
@schematics/angular               0.6.8
@schematics/update                0.6.8
rxjs                              6.2.1
typescript                        2.7.2
webpack                           4.8.3

Is there anything else we should know?

I realize this might not be an Angular/Universal issue, really. But I've been searching the web for hours to find any clues on this and I'm just simply stuck. Need to elaborate some thoughts.

Like...

  1. I've never seen this export syntax, using the file path without require(). Is it valid? In what ES-syntax or NodeJS version (maybe I'm using wrong)?

  2. If I change the line to one of the following, the server starts without errors:

module.exports = require('webpack/buildin/module.js');
module.exports = require('./../../../frontend/website/node_modules/webpack/buildin/module.js');

Again - is the generated syntax valid?
The second line works with an additional '../'. Is the generated path incorrect or has this new bare-path-syntax different relative path than e.g. require()?

Any thoughts is appreciated.

repro steps

Most helpful comment

Same problem here! Please can anyone check this error with the repo provided!?

All 6 comments

is the generated syntax valid

Nope, that generated path is not a valid import or require.

There's not really much I can do without a minimal reproduction or some more details on the topic

@Toxicable asked for a reproduction months ago. If one is provided we can reopen this issue.

@denkan I had the same issue. After installing webpack-cli locally it worked.

I'm having the same problem, installing webpack-cli locally didn't fix it for me..

here's a reproducible repo https://github.com/khaledosman/advanced-angular-features-demo/tree/ssr-implementation

Steps to reproduce:

  1. checkout the ssr-implementation branch
  2. run npm run-script ssr:dev from the client/ directory or webpack --config webpack.server.config.js && node dist/server.js from the server/ directory

Same problem here! Please can anyone check this error with the repo provided!?

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._

Was this page helpful?
0 / 5 - 0 ratings