misea / followers_to_csv

1 stars 0 forks source link

crash trying to import "Papa" from papaparse #1

Open paranoidfactoid opened 1 year ago

paranoidfactoid commented 1 year ago

Hey, trying to use this on Ubuntu20.04 with the official node.js installation. Here's what I get:

foobarbaz@bukowski:~/mastodon-tools/bin/followers_to_csv-main$ node followers_csv.js @paranoidfactoid@mastodon.social followers-Jan-17-2023.csv /home/foobarbaz/mastodon-tools/bin/followers_to_csv-main/followers_csv.js:1 import Papa from "papaparse"; ^^^^

SyntaxError: Unexpected identifier at Module._compile (internal/modules/cjs/loader.js:723:23) at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10) at Module.load (internal/modules/cjs/loader.js:653:32) at tryModuleLoad (internal/modules/cjs/loader.js:593:12) at Function.Module._load (internal/modules/cjs/loader.js:585:3) at Function.Module.runMain (internal/modules/cjs/loader.js:831:12) at startup (internal/bootstrap/node.js:283:19) at bootstrapNodeJSCore (internal/bootstrap/node.js:623:3) foobarbaz@bukowski:~/mastodon-tools/bin/followers_to_csv-main$

misea commented 1 year ago

Looks like your version of node doesn't support ECMAScript modules which are the new(ish) standard. Try running node -v to see your version. ECMAScript module support should date back to Node 14 in 2020 - I am running node 18, which is the latest Long Term Support version. The package.json includes "type":"module" which indicates that this code uses ECMAScript modules.

See here: https://nodejs.org/docs/latest-v18.x/api/packages.html#determining-module-system

paranoidfactoid commented 1 year ago

Yup. I installed via the distribution packages and I got Node 10.

foobarbaz@bukowski:\~$ node -v v10.19.0 foobarbaz@bukowski:\~$

OK. So I have to upgrade this to a new node version, which means either rolling my own or finding a PPA package somewhere. Thanks for your help though. This is a tool I very much want.

paranoidfactoid commented 1 year ago

OK. So I used a PPA to install node 16.19. Still doesn't work. Says fetch is not defined.

...

foobarbaz@bukowski:~/mastodon-tools/bin/followers_to_csv-main$ node -v v16.19.0 foobarbaz@bukowski:~/mastodon-tools/bin/followers_to_csv-main$ node followers_csv.js @paranoidfactoid@mastodon.social followers-jan-21-2023.csv ReferenceError: fetch is not defined at getPublicJson (file:///home/foobarbaz/mastodon-tools/bin/followers_to_csv-main/accounts.js:91:15) at getAccount (file:///home/foobarbaz/mastodon-tools/bin/followers_to_csv-main/accounts.js:7:25) at getFollowers (file:///home/foobarbaz/mastodon-tools/bin/followers_to_csv-main/accounts.js:42:25) at saveFollowersCsv (file:///home/foobarbaz/mastodon-tools/bin/followers_to_csv-main/followers_csv.js:32:28) at file:///home/foobarbaz/mastodon-tools/bin/followers_to_csv-main/followers_csv.js:46:11 at ModuleJob.run (node:internal/modules/esm/module_job:193:25) at async Promise.all (index 0) at async ESMLoader.import (node:internal/modules/esm/loader:530:24) at async loadESM (node:internal/process/esm_loader:91:5) at async handleMainPromise (node:internal/modules/run_main:65:12) file:///home/foobarbaz/mastodon-tools/bin/followers_to_csv-main/accounts.js:11 throw new Error(Error attempting to get account information for ${handle}); ^

Error: Error attempting to get account information for @paranoidfactoid@mastodon.social at getAccount (file:///home/foobarbaz/mastodon-tools/bin/followers_to_csv-main/accounts.js:11:11) at async getFollowers (file:///home/foobarbaz/mastodon-tools/bin/followers_to_csv-main/accounts.js:42:19) at async saveFollowersCsv (file:///home/foobarbaz/mastodon-tools/bin/followers_to_csv-main/followers_csv.js:32:22) at async file:///home/foobarbaz/mastodon-tools/bin/followers_to_csv-main/followers_csv.js:46:5 foobarbaz@bukowski:~/mastodon-tools/bin/followers_to_csv-main$

paranoidfactoid commented 1 year ago

Had to install node 18, then it worked!