Skip to content

[Question] Issue with deploying model to Vercel using NextJS and tRPC #295

@arnabtarwani

Description

@arnabtarwani

Hi I'm trying to deploy my model to Vercel via NextJS and tRPC and have the .cache folder generated using the postinstall script

// @ts-check
let fs = require("fs-extra");
let path = require("path");

async function copyXenovaToLocalModules() {
  const paths = [["../../../node_modules/@xenova", "../node_modules/@xenova"]];

  for (const pathTuple of paths) {
    const [src, dest] = [
      path.join(__dirname, pathTuple[0]),
      path.join(__dirname, pathTuple[1]),
    ];
    await fs.remove(dest).catch(() => {});
    await fs.copy(src, dest).catch(() => {});

    // Create .cache folder for dest paths

    const cacheDir = path.join(dest, "transformers", ".cache");
    await fs.mkdir(cacheDir).catch(() => {});
  }
}

copyXenovaToLocalModules();

When I run this, I get the following error:

env {
  backends: {
    onnx: { wasm: [Object], webgl: {}, logLevelInternal: 'warning' },
    tfjs: {}
  },
  __dirname: '/vercel/path0/packages/api/node_modules/@xenova/transformers',
  version: '2.5.4',
  allowRemoteModels: true,
  remoteHost: 'https://huggingface.co/',
  remotePathTemplate: '{model}/resolve/{revision}/',
  allowLocalModels: true,
  localModelPath: '/vercel/path0/packages/api/node_modules/@xenova/transformers/models/',
  useFS: true,
  useBrowserCache: false,
  useFSCache: true,
  cacheDir: '/vercel/path0/packages/api/node_modules/@xenova/transformers/.cache/',
  useCustomCache: false,
  customCache: null
}
An error occurred while writing the file to cache: [Error: ENOENT: no such file or directory, mkdir '/vercel'] {
  errno: -2,
  code: 'ENOENT',
  syscall: 'mkdir',
  path: '/vercel'
}
An error occurred while writing the file to cache: [Error: ENOENT: no such file or directory, mkdir '/vercel'] {
  errno: -2,
  code: 'ENOENT',
  syscall: 'mkdir',
  path: '/vercel'
}
An error occurred while writing the file to cache: [Error: ENOENT: no such file or directory, mkdir '/vercel'] {
  errno: -2,
  code: 'ENOENT',
  syscall: 'mkdir',
  path: '/vercel'
}

Can someone help me with this?

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions