Skip to main content
Question

Error importing xlsx node library

  • November 1, 2022
  • 0 replies
  • 810 views

Wes_Barichak

I’m working off the default project template that’s created by Figma. I’ve installed xlsx into my project (https://www.npmjs.com/package/xlsx), and I can import into my code.ts without any errors:
import * as XLSX from './node_modules/xlsx/types/index'
That projects comes with it’s own typings.

However, when I run the plugin, it crashes immediately with: Error: Syntax error on line 1: Unexpected token.

I’ve tried switching it to this style of import with the same result:

import { set_fs, utils, writeFile } from './node_modules/xlsx/types/index';

I’ve ensured that the typings root for xlsx is in tsconfig:

"typeRoots": [
      "./node_modules/@types",
      "./node_modules/@figma",
      "./node_modules/xlsx/types"
    ]

Without the import statement in my ts file, vs code doesn’t recognize my usage of XLSX (which is kinda thought was part of the point of providing a typings file).

Any tips for how to properly configure my project? Could it just be that this xlsx library is not supported?

Edit: Not sure if this is related, but I see errors in my @figma\plugin-typings file:

And a lot of similar sounding errors in node typings files as. It’s gotta be some sort of issue with my project configuration, but I’m at a loss as to what.

0 replies

Be the first to reply!

Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings