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 #107

Closed
theprantadutta opened this issue Jan 5, 2021 · 8 comments
Closed

SyntaxError: Cannot use import statement outside a module #107

theprantadutta opened this issue Jan 5, 2021 · 8 comments
Labels
bug Something isn't working

Comments

@theprantadutta
Copy link

Hi, I am having this issue suddenly. I don't know where this came from. My code was working last night but now I am having this error.

Server Error
SyntaxError: Cannot use import statement outside a module

Screenshot
This is my code...

const { register, handleSubmit, errors, setError } = useForm<LoginFormValues>(
    {
      resolver: yupResolver(loginValidationSchema),
      mode: "onTouched",
      reValidateMode: "onBlur",
    }
  );

Inside the form:

<form className="mt-10" onSubmit={handleSubmit(onSubmit)}>
            <InputTextField
              type="email"
              name="email"
              label="Email Address"
              error={errors.email?.message}
              placeholder="youremail@email.com"
              register={register}
            />
            <div className="mt-6">
              <InputTextField
                type="password"
                name="password"
                label="Password"
                error={errors.password?.message}
                placeholder="Enter Your Password"
                register={register}
              />
            </div>

            <div className="mt-6">
              <button type="submit"
              >
                Log In
              </button>
            </div>
          </form>

I can't recreate this error in the code sandbox. It's showing me some other errors. I am so confused right now. BTW, I am using nextjs with typescript

@bluebill1049
Copy link
Member

which version are you using?

@theprantadutta
Copy link
Author

"@hookform/resolvers": "^1.3.2",
"react-hook-form": "^6.14.0",

@theprantadutta
Copy link
Author

theprantadutta commented Jan 5, 2021

It's probably a bug in your latest release. Because I installed the beta version of this package and it's working fine.

@mt-deva
Copy link

mt-deva commented Jan 5, 2021

Yep same issue

@prumand
Copy link

prumand commented Jan 5, 2021

I have the same issue. Downgrading to 1.3.0 worked for me. Seems to be a duplicate of #100

@jorisre
Copy link
Member

jorisre commented Jan 5, 2021

Same issue as #100

@jorisre jorisre closed this as completed Jan 5, 2021
@mskarimi
Copy link

same issue

import { transformToNestObject } from 'react-hook-form';
^^^^^^
SyntaxError: Cannot use import statement outside a module
at wrapSafe (internal/modules/cjs/loader.js:979:16)
at Module._compile (internal/modules/cjs/loader.js:1027:27)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
at Module.load (internal/modules/cjs/loader.js:928:32)
at Function.Module._load (internal/modules/cjs/loader.js:769:14)
at Module.require (internal/modules/cjs/loader.js:952:19)
at require (internal/modules/cjs/helpers.js:88:18)
at Object. (/home/mohamad/Android/Projects/Website/ismv-website/node_modules/@hookform/resolvers/yup.js:1:18)
at Module._compile (internal/modules/cjs/loader.js:1063:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)

"@hookform/resolvers": "^1.3.4",
"react-hook-form": "^6.15.2",

@jorisre
Copy link
Member

jorisre commented Feb 20, 2021

@mskarimi Please have a look to #71 (comment)

@jorisre jorisre added bug Something isn't working and removed Need more detail labels Feb 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

6 participants