S
S
Sashqa2020-01-28 12:32:36
Node.js
Sashqa, 2020-01-28 12:32:36

Another error in node js export?

export { default as add } from './add.js';
^^^^^^

SyntaxError: Unexpected token export


Error in lodash

from lodash import only tsconfig file

import { get, isNil } from 'lodash-es';

{
  "compileOnSave": false,
  "compilerOptions": {
    "importHelpers": true,
    "outDir": "./dist/out-tsc",
    "baseUrl": "./",
    "sourceMap": true,
    "declaration": false,
    "moduleResolution": "node",
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "target": "es5",
    "allowJs": true,
    "typeRoots": [
      "node_modules/@types"
    ],
    "lib": [
      "es2016",
      "dom",
      "esnext.asynciterable",
      "esnext.array",
      "es2017.object"
    ],
    "module": "commonjs"
  }
}


What could be the problem?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
Robur, 2020-01-28
@Sashqa

This is a re-export (import+export in one statement).
You either need a more recent node or use the lodash module instead of lodash-es

A
Alexander, 2020-01-28
@Seasle

This design should have import.
And exportspelled differently

const greeting = (name) => console.log(`Hello, ${name}`);

export default greeting;
/* или */
export { greeting };
And import'ыit will be different for both cases. For the first and for the secondimport greeting from './file.js';import { greeting } from './file.js';

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question