vercel / next.js

The React Framework
https://nextjs.org
MIT License
125.56k stars 26.82k forks source link

Cannot use import statement outside a module - With-Ant Design Error #20143

Closed dukesx closed 3 years ago

dukesx commented 3 years ago

Bug report

Describe the bug

When i try to import Typography or other modules, it gives me an error "Cannot use import statement outside a module"

Error Stack is from file:///C:/Users/username/Desktop/app/node_modules/%20(ctrl/tinycolor/dist/modern/public_api.js (1)

and i am not using tinycolor library, seems part of ant design.

To Reproduce

Steps to reproduce the behavior, please provide code snippets or a repository:

  1. Import Typography as an example
  2. Access Typogaphy.Text or any other Typography module
  3. Reload page
  4. See error

Even if you import it like

const {Text} = Typography

it still gives same error

Expected behavior

Expected behavior is that this error doesn't originate.

Screenshots

None

System information

Additional context

Package.json
{
  "name": "app_name",
  "version": "0.1.0",
  "private": true,
  "scripts": {
    "dev": "next dev",
    "build": "next build",
    "start": "next start",
    "gulp": "npx gulp less"
  },
  "dependencies": {
    "@apollo/client": "^3.1.1",
    "@editorjs/checklist": "^1.1.0",
    "@editorjs/code": "^2.5.0",
    "@editorjs/delimiter": "^1.1.0",
    "@editorjs/editorjs": "latest",
    "@editorjs/embed": "^2.3.1",
    "@editorjs/header": "^2.5.0",
    "@editorjs/image": "^2.5.0",
    "@editorjs/inline-code": "^1.3.1",
    "@editorjs/link": "^2.2.1",
    "@editorjs/list": "^1.5.0",
    "@editorjs/marker": "^1.2.2",
    "@editorjs/paragraph": "^2.8.0",
    "@editorjs/quote": "^2.3.0",
    "@editorjs/simple-image": "^1.3.3",
    "@editorjs/table": "^1.2.2",
    "@editorjs/underline": "^1.0.0",
    "@editorjs/warning": "^1.1.1",
    "@egjs/flicking-plugins": "^3.3.0",
    "@egjs/react-flicking": "^3.3.1",
    "@hcaptcha/react-hcaptcha": "^0.2.1",
    "@next/bundle-analyzer": "latest",
    "@tailwindcss/typography": "^0.2.0",
    "antd": "latest",
    "autoprefixer": "^10.0.2",
    "babel-plugin-import": "latest",
    "cross-env": "^7.0.2",
    "date-fns": "^2.16.1",
    "easy-peasy": "^4.0.1",
    "editorjs-github-gist-plugin": "^1.1.0",
    "editorjs-inline-image": "^0.1.1",
    "editorjs-social-post-plugin": "^1.0.0",
    "editorjs-undo": "^0.1.4",
    "esm": "^3.2.25",
    "graphql": "latest",
    "gulp": "^4.0.2",
    "gulp-csso": "^4.0.1",
    "gulp-debug": "^4.0.0",
    "gulp-less": "^4.0.1",
    "gulp-postcss": "^9.0.0",
    "less-plugin-npm-import": "^2.1.0",
    "nanoid": "^3.1.12",
    "next": "10.0.0",
    "next-auth": "^3.1.0",
    "next-pwa": "^3.1.4",
    "next-seo": "^4.10.0",
    "postcss": "8.1.7",
    "postcss-preset-env": "latest",
    "react": "latest",
    "react-css-theme-switcher": "^0.1.6",
    "react-dom": "latest",
    "remixicon": "^2.5.0",
    "sass": "^1.30.0",
    "subscriptions-transport-ws": "^0.9.18",
    "tailwindcss": "^2.0.1",
    "tailwindcss-line-clamp": "^1.0.5",
    "use-dark-mode": "^2.3.1"
  },
  "browser": {
    "fs": false,
    "path": false
  }
}
jamesmosier commented 3 years ago

Hi @dukesx. I wasn't able to reproduce using the with-ant-design example. Could you please include a repository showing this issue?

It sounds like you are using a module that needs transpiled.

dukesx commented 3 years ago

Hi @dukesx. I wasn't able to reproduce using the with-ant-design example. Could you please include a repository showing this issue?

It sounds like you are using a module that needs transpiled.

Please update ant Design in the example to 4.9 (current). That Repo is using version 4.0.3 which is year older I guess. Then try again.

leerob commented 3 years ago

Closing as there's no reproducible example, and @jamesmosier was not able to reproduce. If someone is interested in updating the Ant Design example, we can reopen this for that 😄

Thank you!

balazsorban44 commented 2 years ago

This issue has been automatically locked due to no recent activity. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.