How to meteor npm install xenova/transfomers?

Any idea?

$meteor npm install xenova/transformers
npm ERR! addLocal Could not install /tmp/npm-474-df1c28dc/git-cache-92401/cee17085914bbe505c159beeb8ae39bc37dd
npm ERR! git rev-list -n1 master: fatal: ambiguous argument ‘master’: unknown revision or path not in the working tree.
npm ERR! git rev-list -n1 master: Use ‘–’ to separate paths from revisions, like this:
npm ERR! git rev-list -n1 master: ‘git […] – […]’
npm ERR! git rev-list -n1 master:
npm ERR! addLocal Could not install /tmp/npm-474-df1c28dc/git-cache-ea81f/17085914bbe505c159beeb8ae39bc37dd

Hi @carrot93 did you miss the @ before xenova/transformers by any chance? The following code installed it for me

$ meteor npm install @xenova/transformers

> sharp@0.32.6 install /home/username/dev/poc/chatsrv/node_modules/sharp
> (node install/libvips && node install/dll-copy && prebuild-install) || (node install/can-compile && node-gyp rebuild && node install/dll-copy)

sharp: Downloading https://github.com/lovell/sharp-libvips/releases/download/v8.14.5/libvips-8.14.5-linux-x64.tar.br
sharp: Integrity check passed for linux-x64

> protobufjs@6.11.4 postinstall /home/username/dev/poc/chatsrv/node_modules/protobufjs
> node scripts/postinstall

npm WARN notsup Unsupported engine for @huggingface/jinja@0.2.2: wanted: {"node":">=18"} (current: {"node":"14.21.4","npm":"6.14.18"})
npm WARN notsup Not compatible with your version of node/npm: @huggingface/jinja@0.2.2

+ @xenova/transformers@2.17.2
added 79 packages from 274 contributors and audited 189 packages in 28.855s

39 packages are looking for funding
  run `npm fund` for details

found 1 high severity vulnerability
  run `npm audit fix` to fix them, or `npm audit` for details

However, as you can see the peer dependencies require Node>=18 and will likely not work on a Meteor 2.x project. If I do this with a Meteor 3.0-rc.2 project it works without any warning:

meteor npm install @xenova/transformers
npm WARN old lockfile 
npm WARN old lockfile The package-lock.json file was created with an old version of npm,
npm WARN old lockfile so supplemental metadata must be fetched from the registry.
npm WARN old lockfile 
npm WARN old lockfile This is a one-time fix-up, please be patient...
npm WARN old lockfile 

up to date, audited 190 packages in 3s

39 packages are looking for funding
  run `npm fund` for details

1 high severity vulnerability

To address all issues, run:
  npm audit fix

Run `npm audit` for details.

Note the audit issue is not coming from @xenova/transformers

@jkuester

Did you try an import on the client after installing?

import { pipeline } from '@xenova/transformers';

I get the following errors

@petr24 maybe the package is not built to run in the browser but only on the server?

@jkuester According to the documentation, it’s explicitly designed for the client. However, I tried server only, and I get the same error.

I’ve had to use npm patch to fix. __dirname with meteor is causing a conflict, not sure why since it works in plain node js no issue.

In the meantime here is what I did to make it work.

// Original __dirname
// const __dirname = RUNNING_LOCALLY
//     ? path.dirname(path.dirname(url.fileURLToPath(import.meta.url)))
//     : './';

const __dirnameB = RUNNING_LOCALLY
    ? path.dirname(path.dirname(__filename))

// ... Replace all instances of __dirname with ___dirnameB

I have the suspicion, that this has something to do with Meteor ignoring “exports” field of the npm modules package.json :thinking: Similar issue here: Feature: Support package.json exports fields · meteor/meteor · Discussion #11727 · GitHub

Interesting, don’t think it applies for @xenova/transformers, since no “exports” key in the transformers package.json.

The exports issue definitely effects things like upgrading Svelte version to 4.x and 5 when it launches.