(TSDX Jest) SyntaxError: Cannot use import statement outside a moduleSee original GitHub issue
I am using node-fetch api and when I run
yarn run test, I get the following error:
System: OS: macOS 11.5.2 CPU: (8) x64 Intel(R) Core(TM) i7-7920HQ CPU @ 3.10GHz Memory: 125.96 MB / 16.00 GB Shell: 5.8 - /bin/zsh Binaries: Node: 12.22.4 - ~/.nvm/versions/node/v12.22.4/bin/node Yarn: 1.22.10 - /usr/local/bin/yarn npm: 7.20.3 - ~/.nvm/versions/node/v12.22.4/bin/npm Browsers: Chrome: 93.0.4577.82 Firefox: 89.0.2 Safari: 14.1.2 npmPackages: tsdx: ^0.14.1 => 0.14.1 typescript: ^4.4.3 => 4.4.3 npmGlobalPackages: typescript: 4.4.3
I choose this package/lib because I don’t know much about configuration stuff (Jest, node, tsconfig) but apparently I am stuck and can’t find any solution. Can you please let me know what am I missing here?
- Created 2 years ago
Top GitHub Comments
I figured it out. While installing
@babel/plugin-transform-modules-commonjs I saw a warning saying I should also install
jest-babel which is not required, removing it solved the problem. Thanks a lot for your help 😃
I have the same issue.
I’m trying to import something to a test file but still get
SyntaxError: Cannot use import statement outside a module.
In my opinion, the issue should be reopened as the problem still occurs on the master branch.