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

Closed
cckz opened this issue Feb 9, 2021 · 6 comments
Closed

SyntaxError: Cannot use import statement outside a module #77

cckz opened this issue Feb 9, 2021 · 6 comments

Comments

@cckz
Copy link

cckz commented Feb 9, 2021

hi, bundle crashes after last update

Documents\projects\sed_flexible_reports\node_modules\@ctrl\tinycolor\dist\module\conversion.js:1
import { bound01, pad2 } from './util';
^^^^^^

SyntaxError: Cannot use import statement outside a module
    at compileFunction (<anonymous>)
    at wrapSafe (internal/modules/cjs/loader.js:1071:16)
    at Module._compile (internal/modules/cjs/loader.js:1121:27)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1177:10)
    at Module.load (internal/modules/cjs/loader.js:1001:32)
    at Function.Module._load (internal/modules/cjs/loader.js:900:14)
    at Module.require (internal/modules/cjs/loader.js:1043:19)
    at require (internal/modules/cjs/helpers.js:77:18)
    at Object.<anonymous> (Documents\projects\sed_flexible_reports\node_modules\@ant-design\colors\dist\index.js:5:18)
    at Module._compile (internal/modules/cjs/loader.js:1157:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1177:10)
    at Module.load (internal/modules/cjs/loader.js:1001:32)
    at Function.Module._load (internal/modules/cjs/loader.js:900:14)
    at Module.require (internal/modules/cjs/loader.js:1043:19)
    at require (internal/modules/cjs/helpers.js:77:18)
    at Object.<anonymous> (Documents\projects\sed_flexible_reports\node_modules\@ant-design\icons\lib\utils.js:22:15)
    ```

@peterwiebe
Copy link

I also ran into this problem. I am able to fix it by going into node_modules/@ant-design/colors/dis/index.js and changing

var conversion = require('@ctrl/tinycolor/dist/module/conversion');
var formatInput = require('@ctrl/tinycolor/dist/module/format-input');

to this

var conversion = require('@ctrl/tinycolor/dist/conversion');
var formatInput = require('@ctrl/tinycolor/dist/format-input');

@peterwiebe
Copy link

peterwiebe commented Feb 9, 2021

or for a more semi-permanent fix until a new release is published is to add the following to package.json until the breaking change is fixed (if you use yarn):

"resolutions": {
  "@ant-design/colors": "5.0.0"
}

@jamsinclair
Copy link

jamsinclair commented Feb 10, 2021

/cc @zombieJ @07akioni

For a quick summary, this breaking change might be caused by tree shaking code being included in v5.1.0.

Looks like @zombieJ has fixed this in #75. Hopefully, a new patch release with that commit will resolve this for everyone?

Appreciate the work you all do on this 😸 , many thanks!

@zombieJ
Copy link
Member

zombieJ commented Feb 10, 2021

0f15e95

@zombieJ zombieJ closed this as completed Feb 10, 2021
@jamsinclair
Copy link

@zombieJ thanks for the quick fix 🙌 . Anything blocking publishing v5.1.1 to npm? 🙏

@iamricky
Copy link

@cckz are you using Next.js?

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

No branches or pull requests

5 participants