Skip to content

How to use the file that I uploaded when I create template #1049

@Helios-Shao

Description

@Helios-Shao

I have create a template:

import { Template } from 'e2b'

export const template = Template()
  .fromImage('e2bdev/base')
  .runCmd('echo Hello World E2B!').setWorkdir('/app').copy('./skills', '/app/skills').copy('./basic_utils.js', '/app/basic_utils.js')

However, when I import utils.js in the skills. it report "cannot find module"
This is my code that run in the sandbox

import {get_a_batch_of_location} from 'file:///app/skills/utils.js'

let store_info = {
    store_name: "",
    access_token: ""
}

console.log(store_info)

it is the specific error message:

error: ExecutionError {
    name: 'Error',
    value: "Cannot find module '/app/skills/utils.js'\n" +
      'Require stack:\n' +
      '- /home/user/[eval]',
    traceback: "node:internal/modules/cjs/loader:1210  throw err;  ^Error: Cannot find module '/app/skills/utils.js'Require stack:- /home/user/[eval]    at Module._resolveFilename (node:internal/modules/cjs/loader:1207:15)    at Module._load (node:internal/modules/cjs/loader:1038:27)    at Module.require (node:internal/modules/cjs/loader:1289:19)    at require (node:internal/modules/helpers:182:18)    at evalmachine.<anonymous>:1:14    at Script.runInThisContext (node:vm:137:12)    at Object.runInThisContext (node:vm:317:38)    at run ([eval]:1020:21)    at onRunRequest ([eval]:864:24)    at onMessage ([eval]:828:19)"
  },
  executionCount: 1
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions