CLARIAH / vocabulary-recommender

4 stars 0 forks source link

'fetch is not defined' #9

Closed rlzijdeman closed 1 year ago

rlzijdeman commented 1 year ago

Hi, I think I successfully installed the vocabulary recommender using GitHub. When running the command yarn recommend -t person -c class I expected recommendations of terms , but got fetch is not defined instead. Any suggestions?

My output below:


user@machine vocabulary-recommender % ls
README.md       package-lock.json   src         txt
confSparql.json     package.json        tsconfig.json       yarn.lock
user@machine vocabulary-recommender % yarn
yarn install v1.22.19
warning package-lock.json found. Your project contains lock files generated by tools other than Yarn. It is advised not to mix package managers in order to avoid resolution inconsistencies caused by unsynchronized lock files. To clear this warning, remove package-lock.json.
[1/4] πŸ”  Resolving packages...
[2/4] 🚚  Fetching packages...
[3/4] πŸ”—  Linking dependencies...
[4/4] πŸ”¨  Building fresh packages...
✨  Done in 2.08s.
user@machine vocabulary-recommender % yarn build
yarn run v1.22.19
$ tsc
✨  Done in 2.17s.
user@machine vocabulary-recommender % yarn recommend -t person -c class
yarn run v1.22.19
$ node ./dist/recommend.js -t person -c class
'vocabulary_recommender' folder not found in home directory, creating folder...
Folder generated in: /Users/richardz/vocabulary_recommender
Endpoint configuration file 'vocabulary-recommender.json' is not found in the '~/vocabulary_recommender' folder, creating endpoint configuration file...
File generated in: /Users/richardz/vocabulary_recommender/vocabulary-recommender.json
(!) No endpoints were provided, using the default endpoint: druid-recommend (!)
fetch is not defined
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
user@machine vocabulary-recommender %```
philipperenzen commented 1 year ago

This error seems to appear due to node versioning issues. The fetch function became a built in function in node version 18, but sadly it is not available in previous versions of node.js.

In the most recent commit, I changed it so the library uses 'node-fetch' package, which will prevent this problem with different node versions.

Thank you for your feedback!