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

EE is not a constructor #1222

Closed
jakob-fuchs opened this issue Aug 15, 2018 · 13 comments
Closed

EE is not a constructor #1222

jakob-fuchs opened this issue Aug 15, 2018 · 13 comments

Comments

@jakob-fuchs
Copy link

I'm following this tutorial here: https://redstapler.co/sheetjs-tutorial-convert-excel-html-table/

The error message I get is: Uncaught TypeError: Ee is not a constructor

My code is here: https://kind-knuth-cf9a2f.netlify.com/ https://kind-knuth-cf9a2f.netlify.com/index.js

Since I don't know much about this library I don't have any clue why that is happening. I'd appreciate any help.

@oliver-la
Copy link

I don't think it has something to do with your code. I've been using similar code for 4 weeks and it broke just recently. Jumping back in my commit history back 4 weeks ago makes no difference, the same exception is thrown.

Tried downgrading via NPM down to 0.13.1 and also using the current master branch state.

Oddly enough the angular2 (angular5) demo works flawlessly. There must be something we're missing.

ng --version

Angular CLI: 6.1.4
Node: 8.11.1
OS: darwin x64
Angular: 6.0.7
... animations, common, compiler, core, forms, http
... language-service, platform-browser, platform-browser-dynamic
... router

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.7.4
@angular-devkit/build-angular     0.7.2
@angular-devkit/build-optimizer   0.7.2
@angular-devkit/build-webpack     0.7.2
@angular-devkit/core              0.7.4
@angular-devkit/schematics        0.7.4
@angular/cli                      6.1.4
@angular/compiler-cli             6.0.6
@ngtools/webpack                  6.1.2
@schematics/angular               0.7.4
@schematics/update                0.7.4
rxjs                              6.2.1
typescript                        2.7.2
webpack                           4.9.2

@SheetJSDev
Copy link
Contributor

@jakob-fuchs @xama5 can you try rolling back to Angular 5.x?

@oliver-la
Copy link

woah, thanks for the quick reply @SheetJSDev!

As typical, I figured it out just after posting my comment.

The issue seems not to be with the angular version, it lies in the wrong import I used:

Breaks:
import * as XLSX from 'xlsx/dist/xlsx.min';

Works:
import * as XLSX from 'xlsx';

This creeped in just before my recent 40 commits, so obviously a typical user/programmer error.

@jakob-fuchs has it probably the same

@jakob-fuchs
Copy link
Author

I'm loading the xlsx.min file form the dist directory with a script tag. I guess that's the correct way?

@oliver-la
Copy link

oliver-la commented Aug 21, 2018

In the demo you provided you're not using the full dist.

It should be

<script src="./node_modules/xlsx/dist/xlsx.full.min.js"></script>

instead of

<script src="./node_modules/xlsx/dist/xlsx.min.js"></script>

Can you verify?

@jakob-fuchs
Copy link
Author

Yes, I missed that. Thanks for catching that.

@brickspert
Copy link

import XLSX from 'xlsx/dist/xlsx.full.min'; work for me!
but import XLSX from 'xlsx'; or import XLSX from 'xlsx/dist/xlsx.min'; not work for me!

early, i use import XLSX from 'xlsx', it work! but now ,it not work! why??

@oliver-la
Copy link

@brickspert Read my reply more carefully.

It should be import * as XLSX from 'xlsx';

Everything else will not work.

@brickspert
Copy link

brickspert commented Nov 19, 2018

@xama5 no,i used import * as XLSX from 'xlsx' one month ago, it worked for me!

but, it broke just recently. the error message is ke is not a constructor.

i have not change any code ,

i must change it to import XLSX from 'xlsx/dist/xlsx.full.min', it works for me!

so , i don't know why~~

@oliver-la
Copy link

@brickspert That's strange. Do you have your code somewhere on GitHub?

@brickspert
Copy link

@xama5 no, it's a private project. i think that's so strange !

now i use import XLSX from 'xlsx/dist/xlsx.full.min', it work for me .

some days ago, i use import * as XLSX from 'xlsx' . but now ,it not work!

are you chinese??

@oliver-la
Copy link

@brickspert Hmm, I'd suggest to delete the node_modules directory and install everything again. But without code I'm unable to help. If you don't want to share your code, then I suggest you create a demo where the issue is reproduced. Also check out these demos and see if your code is the same: https://github.com/SheetJS/js-xlsx/tree/master/demos

You can also try going a version back of this package. If only the most recent version breaks, kindly create a new issue.

And no, unfortunately I'm not Chinese. :)

@selcukoguz
Copy link

@brickspert it work for me to. I think because of routes includes lazy component.

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