1

I downloaded the harrison:papa-parse package : meteor add harrison:papa-parse. But now i need to load it in my Meteor application so i can use it.

I imported the package in my Component :

import { Papa } from 'meteor/harrison:papa-parse';

and then i need to declare the module in typing.d.ts file

declare module 'meteor/harrison:papa-parse' {
  // something here like export const Papa; ?
}

, but after that i'm lost ! and i have an error: cannot read property 'parse' of undefined

In My component :

Papa.parse("http://mywebsite/test.csv", {
        download: true,
        complete: function(results) {
            console.log(results);
        }
      });

Maybe there's an easy way to import the package easly and i'm trying to complicate it ?

Kivo
  • 385
  • 8
  • 24

2 Answers2

0

The meteor package exports the "Papa" variable on the server, which means you have to call it from a server process.

Delete this line from your code, because it won't do anything:

import { Papa } from 'meteor/harrison:papa-parse';

Meteor packages don't need to be imported, part of the package spec is an automatic import of whatever variables are needed.

According to the documentation this package should be available in the browser, but for some reason the meteor package author made the decision to only expose it in the server.

There is also an npm package available, which might be a better path for you to follow.

Mikkel
  • 7,693
  • 3
  • 17
  • 31
0

You don't need the harrison:papa-parse meteor package. You can install and use the papaparse NPM package directly. In the root of your meteor project run meteor npm install --save papaparse. Then, in your client script you can import with import Papa from 'papaparse';.

Sean
  • 4,365
  • 1
  • 27
  • 31