Sheetjs: Can't install with @angular/cli

Created on 24 Nov 2017  路  4Comments  路  Source: SheetJS/sheetjs

I tried to install js-xlsx on an Angular2 project build with angular-cli but I failed and have no clue what I missed.
Every time I launch the command "ng serve" I get the message "Cannot find module 'xlsx'" refering to the line "import * as XLSX from 'xlsx';"

I tried a lot of things :

  • First, I only did "npm install --save xlsx" and import the lib in my component with "import * as XLSX from 'xlsx';"
  • Then I tried to add typings with "npm install --save @types/xlsx"
  • I also tried to manually add the js file into angular-cli.json :
    "scripts": [
    "../node_modules/xlsx/dist/xlsx.full.min.js"
    ],
  • I tried to install jszip because it seems to be a dependency

What am I missing ?
Can somebody help me ?

Most helpful comment

I am sorry, but NO, your demo does not work.
When I launch the 'npm run start' command I get the error "ERROR in src/app/sheetjs.component.ts(5,23): error TS2307: Cannot find module 'xlsx'." exactly the same that when I do it on my own project.

I tried to modify the tsconfig.json file based on #610 example, without any success.

All 4 comments

The demo in https://github.com/SheetJS/js-xlsx/tree/master/demos/angular2 still works in angular2. Based on https://github.com/SheetJS/js-xlsx/issues/610#issuecomment-345380519 you probably need to add some of the fields from the demo tsconfig.json.

I am sorry, but NO, your demo does not work.
When I launch the 'npm run start' command I get the error "ERROR in src/app/sheetjs.component.ts(5,23): error TS2307: Cannot find module 'xlsx'." exactly the same that when I do it on my own project.

I tried to modify the tsconfig.json file based on #610 example, without any success.

Can you share a small project reproducing the problem?

@RChoque did you install xlsx or js-xlsx? The correct module to install is xlsx:

$ npm install xlsx
Was this page helpful?
0 / 5 - 0 ratings

Related issues

magtuan picture magtuan  路  3Comments

jamespan0 picture jamespan0  路  3Comments

Alex0007 picture Alex0007  路  3Comments

thomasledoux1 picture thomasledoux1  路  3Comments

sudhakar-sekar picture sudhakar-sekar  路  3Comments