The import map is not being recognized by Supabase Edge Functions when passed in the command `npx supabase functions serve`

My situation involves two edge functions, namely create-payment-link and retrieve-payment-link. However, they are currently utilizing the import map located at /home/deno/flag_import_map.json, rather than the import_map.json file within the functions folder. As a result, they are encountering an error stating that x was not mapped in import map. where x represents a specific package they each require.

Both of these functions share the following imports:

import { serve } from "server"
import * as cryptojs from "crypto-js";

import { config } from "dotenv";

The contents of import_map.json are as follows:

{
  "imports": {
    "server": "https://deno.land/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="394a4d5d790917080f011709">[email protected]</a>/http/server.ts",
    "crypto-js": "https://cdn.skypack.dev/crypto-js",
    "dotenv": "https://deno.land/x/dotenv/mod.ts"
  }
}

This issue arises when attempting to locally serve both functions using the command:

npx supabase functions serve --debug --env-file ./supabase/.env --import-map ./supabase/functions/import_map.json

However, serving them individually with

npx supabase functions serve function-name --debug --env-file ./supabase/.env 
seems to work without any problems.

Answer №1

The location is noted at:

https://github.com/supabase/cli/blob/55192fe878c77fa347bb00ba102eadc88d738a3b/internal/functions/serve/serve.go#L27-L28
The script reveals that flag_import_map.json is the one provided through the --import-map option.

I am puzzled as to why they duplicate it in /home/deno/ instead of /home/deno/functions/. Using relative paths in the import-map could potentially disrupt those dependencies.
From what I gather, Seizebase's approach seems to function correctly only for external Deno dependencies.

My recommendation is to leave your import_map.json where it is and allow Deno to handle it independently, without intervention from the Seizebase config-map option.

Answer №2

When working with the config.toml file,

Remember to include the path for import_map.

[functions.tenant-permission-groups-identity]
 verify_jwt = false
 import_map = './import_map.json'

https://example.com/image.png

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

What is the best way to ensure a texture is always facing the camera?

Latest Update: We have created a new demo to showcase the desired outcome. The demo includes an invisible skydome, a cubecamera, and an environment map. However, it is important to note that these techniques should not be utilized for the reasons previous ...

Working with arrays in JavaScript objects

I have an object with arrays nested inside, as shown in the example below: {1: Array(4), 2: Array(4), 3: Array(4)} 1: (4) ["11111", "2020-04-02", "14:07", 1] 2: (4) ["22222", "2020-04-02", "14:07", 2] 3: (4) ["3333333", "2020-04-02", "14:07", 3] (from con ...

Placing text inside a designated element on a different web page upon clicking a button

Imagine a scenario where a user is browsing a website and lands on the 'prices' page. They come across a product that catches their eye and decide to click on the associated button. This action redirects them to the 'contact us' page, w ...

leveraging the static method in a JavaScript class

My dilemma is over which option would be quicker. Should I instantiate a new object from a class and use that, or should I utilize a class with static methods? export default class AuthServices { static async login (data) {} static async register ...

Parsing of CSS and Javascript is disabled within iframes

Within my node.js application, I have configured an endpoint where I can load some parsed HTML code. This is achieved through the following code: app.get('/code', function (req, res) { res.setHeader('Content-Type', 'text/html& ...

Replacing a div with another div can be achieved in a single swap

My goal is to swap one div with another div upon clicking using the provided code. It functions properly for a single instance. However, the issue arises when the class appears multiple times, causing all instances to change due to sharing the same class n ...

for each item, assign a unique ink color

Hello there! Currently, I am working on a straightforward online shopping MVC application. Within this application, there is a table containing three categories: Laptops, Mobiles, and Consoles. I have created a partial view that fetches these categories fr ...

Utilizing db.system.js Function within the $where Clause

Here is an illustration of a basic function that I have saved: db.system.js.save({_id: "sum", value: function (x, y) { return x + y; }}); However, when attempting to call it within the $where clause, a Reference not exist error occurs. <?php $collec ...

Tips on transitioning a Node.js application from JavaScript to TypeScript incrementally

I have a JavaScript node application that has grown quite large and I am considering migrating to TypeScript for faster development and easier code maintenance. I have installed TypeScript along with the node and mocha types using the following commands: ...

What is the best way to apply a class for styling my JavaScript code in CSS? I'm having trouble getting classList

I am having trouble adding a class to my JavaScript script in order to animate the images created in JavaScript to fall off the page. I have tried using the code element.classList.add("mystyle");, but every time I insert it, my JavaScript stops working. T ...

Submitting form data including file uploads using AJAX

Currently, the file is being sent via AJAX using the following code: var fd = new FormData(); //additional actions to include files var xhr = new XMLHttpRequest(); xhr.open('POST', '/Upload/' + ID); xhr.send(fd); In ...

Why does the getOwnPropertyDescriptor() method in JavaScript include custom properties that are inherited?

As I delve into the world of JavaScript and Node.js, a question has arisen regarding the Object.getOwnPropertyDescriptor() function. Let's explore the following snippet of code: var rectangle = { width: 10, height: 5, get area() { ...

Exploring the context of file upload events and analyzing javascript functionality

Can you help me conditionally trigger the file upload dialog using JavaScript based on an Ajax response? <input type="file" id="Upload"> I have hidden the input element as I don't want to display the default file upload button. Instead, ther ...

Discover each *distinct arrangement* from a given array

I'm looking to generate unique combinations of element positions in a JavaScript array. Here's the array I am working with: var places = ['x', 'y', 'z']; The combinations I want are: [0,1], [0,2], [1,2]. Current ...

Sending arguments to a JavaScript function together with a callback

I have a link on my HTML page that looks like this: <a id="save_report" href="javascript:void(0);" title="Save Report" onclick="javascript:enterReportNameToSave(<?php echo $upload_count?>,<?php echo $startOffset;?>,<?php echo $affiliateI ...

Issue with Lodash in Angular 2 causing a Typescript error but still functional

While attempting to incorporate lodash into my angular2 project, I encountered an issue. Although it is functioning properly, I am consistently seeing the following error in my log: TS2307 Cannot find module 'lodash'. [error] import * as _ from ...

Guide to building a seamless page without refreshes with the help of jquery, express, and handlebars

I need assistance with my express JS project. I am trying to set up two pages using NodeJS, incorporating handlebars as the template engine. My objective is to have the first page rendered using res.render('home'), and for the second page to be l ...

Registering modules with System.js in a typescript project involves a specific process

In my TypeScript project, I am trying to concatenate the compiled output into a single file. I am using the SystemJs module, but I am facing an issue where the output changes when I include an 'import' statement in the script files. For example, ...

Ways to extract data from an array nested within a JSON object

I am seeking guidance on how to access the value of "result 2" from my JSON object using jQuery or pure JavaScript. var jsonarray = [{ title: "Category1", items: [{ result: "Item1", //Nested array items2: [{ //How to get the value o ...

Issues with Bootstrap Navigation Collapse Utilizing Data Attributes

I'm having trouble getting a Twitter Bootstrap 3 navbar to collapse using data attributes, as it is not expanding properly. Just to give some context, the project I am working on is an ASP.NET C# MVC project that runs on DNN (DotNetNuke) CMS. When I ...