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.

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

See original GitHub issue

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.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:8
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
Ismaestrocommented, Mar 12, 2019

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

2reactions
ftorghelecommented, Dec 3, 2018

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

javascript - Unexpected token { When running the project on dist
When running this single file, Node.js doesn't know you are trying to run a part of a bigger module. Such import keyword only...
Read more >
SyntaxError: Unexpected token 'export' in JavaScript
The "Uncaught SyntaxError Unexpected token 'export'" occurs for 2 main reasons: Using the ES6 Module syntax in a Node.js application without type to...
Read more >
typescript syntaxerror: unexpected token 'export' - You.com
The code will throw error when it running in browser since browser cannot recognize the ES6 module syntax. The reason is that, by...
Read more >
Unexpected token import Node.js - Reactgo
When we use es6 modules import/export statements in Node.js. It gives a following error in the terminal because node is currently not supporting ......
Read more >
Import React in Node.js throws SyntaxError - appsloveworld.com
[Solved]-Import React in Node.js throws SyntaxError: Unexpected token export-Reactjs. Search. score:2. Accepted answer. "build:all": "babel ./src -d ./dist ...
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