Skip to content
This repository has been archived by the owner on Jun 5, 2019. It is now read-only.

Unexpected token import #106

Open
CzBuCHi opened this issue Dec 28, 2017 · 3 comments
Open

Unexpected token import #106

CzBuCHi opened this issue Dec 28, 2017 · 3 comments
Labels

Comments

@CzBuCHi
Copy link

CzBuCHi commented Dec 28, 2017

when calling npm test i got this error:

 FAIL  test\storyshots.test.ts
  ● Test suite failed to run

    C:\projects\easy-runner\node_modules\lodash-es\flattenDeep.js:1
    ({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,global,jest){import baseFlatten from './_baseFlatten.js';
                                                                                             ^^^^^^

    SyntaxError: Unexpected token import

      at ScriptTransformer._transformAndBuildScript (node_modules/jest-runtime/build/script_transformer.js:305:17)
      at Object.<anonymous> (node_modules/@storybook/react/dist/client/preview/element_check.js:16:20)
      at Object.<anonymous> (node_modules/@storybook/react/dist/client/preview/render.js:31:22)

any idea why is this happening?

PS: also got test fail for "loads from electron" in "src\main\main-window\load-url.test.ts" but that can be fixed by using posix version of path.join

PS>check-node-version --print
node: 9.3.0
npm: 5.6.0
yarn: 1.3.2

PS> systeminfo | findstr /C:"OS"
OS Name:                   Microsoft Windows 10 Home
OS Version:                10.0.15063 N/A Build 15063
OS Manufacturer:           Microsoft Corporation
OS Configuration:          Standalone Workstation
OS Build Type:             Multiprocessor Free
BIOS Version:              American Megatrends Inc. 1708, 10.04.2013
@skellock
Copy link
Owner

Hey, thanks for the issue!

I haven't run the tests from windows yet. There's probably a few places where switching from hardcoded slash paths to path.resolve() will fix up things.

That lodash-es import, was that something specific to your project?

The import statement that it's bombing on is because import isn't a thing on node.js yet. I wonder if switching to a non-es version of lodash would help?

@skellock
Copy link
Owner

Also, https://github.com/standard-things/esm might be able to help as it polyfills import into node.js.

@CzBuCHi
Copy link
Author

CzBuCHi commented Dec 28, 2017

about path: simplest would be to use path.posix.* instead of path.* - it forces path with slashes even on windows

about lodash-es: im getting this error on your code (only git clone', 'npm install' and 'npm test where called) ... switch to non-es lodash can do, because im not who is importing this (lodash is not in package.json) ... now reading about esm .... later

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants