2

I'm getting the following output when trying to build my Angular 8 Universal project. I use Webpack and SSR:

myproject/node_modules/universal-analytics/node_modules/uuid/dist/esm-browser/index.js:1
export { default as v1 } from './v1.js';
^^^^^^

**SyntaxError: Unexpected token 'export'**
    at wrapSafe (internal/modules/cjs/loader.js:1055:16)
    at Module._compile (internal/modules/cjs/loader.js:1103:27)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1159:10)
    at Module.load (internal/modules/cjs/loader.js:988:32)
    at Function.Module._load (internal/modules/cjs/loader.js:896:14)
    at Module.require (internal/modules/cjs/loader.js:1028:19)
    at require (internal/modules/cjs/helpers.js:72:18)
    at Object.<anonymous> (/myProject/node_modules/universal-analytics/lib/index.js:3:12)
    at Module._compile (internal/modules/cjs/loader.js:1139:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1159:10)

It was working perfectly until today when I had to run npm install.

My tsconfig.json

{
  "compileOnSave": false,
  "compilerOptions": {
    "outDir": "./dist/out-tsc",
    "baseUrl": "src",
    "sourceMap": true,
    "declaration": false,
    "moduleResolution": "node",
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "target": "es2015",
    "typeRoots": [
      "node_modules/@types"
    ],
    "lib": [
      "es2016",
      "dom"
    ],
    "module": "esnext",
    "resolveJsonModule": true
  }
}

Has anyone else seen this or got any idea how I can try to resolve?

2
  • 1
    Have a look there github.com/angular/angular-cli/issues/… Commented Jul 3, 2020 at 10:30
  • Thank you for the suggestion. I did find the cause and I'll post the solution. Commented Jul 4, 2020 at 18:08

1 Answer 1

1

This appears to have been caused by NPM caching some of my node_modules so that when I ran a fresh npm i, some modules were not correctly updating. I switched to yarn and that solved the issue :)

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.