Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SyntaxError: Cannot use import statement outside a module #802

Closed
DiggesT opened this issue Mar 15, 2023 · 1 comment
Closed

SyntaxError: Cannot use import statement outside a module #802

DiggesT opened this issue Mar 15, 2023 · 1 comment

Comments

@DiggesT
Copy link

DiggesT commented Mar 15, 2023

What are the steps to reproduce this issue?

  1. use Axios (tried with 1.3.4, 1.3.3 and 1.1.0 versions)
  2. use a .ts mutator with Axios import
  3. use Craco
"scripts": {
  "test": "craco test",
  1. GitHub actions (local test work fine)
- run: npm ci
- run: npm run api ("scripts": "api": "npx orval --prettier")
- run: npm test

What happens?

GitHub action (npm test) failed with SyntaxError: Cannot use import statement outside a module.
The same error using require().

What were you expecting to happen?

Pass test.

Any logs, error output, etc?

GitHub actions log:

    SyntaxError: Cannot use import statement outside a module

    > 1 | import Axios, { AxiosRequestConfig, AxiosPromise, AxiosError } from 'axios'
        | ^
      2 |
      3 | import { getAuthViaCookies, getRecord } from '../../auth'
      4 |

      at Runtime.createScriptFromCode (node_modules/jest-runtime/build/index.js:1728:14)
      at Object.<anonymous> (src/api/mutator/axios-auth.ts:1:1)
      at Object.<anonymous> (src/api/endpoints/auth.ts:16:1)
      at Object.<anonymous> (src/components/LoginForm.tsx:11:1)
      at Object.<anonymous> (src/App.tsx:9:1)
      at Object.<anonymous> (src/App.test.tsx:2:1)

Any other comments?

Repository with error.

If you need more information, let me know.

Seems related to #223.
Axios also have some issues: 5550, 5162.

What versions are you using?

Operating System: Ubuntu 22.04.1 (GitHub actions)
Package Version: Orval 6.12.1 (from 6.11.0)

@melloware
Copy link
Collaborator

Is this still an issue. I use Axios and have never seen this error?

@melloware melloware closed this as not planned Won't fix, can't repro, duplicate, stale Nov 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants