Am getting 404 Not Found trying to access edge-function i have tried so many lesson online but non helped [[edge_functions]] function = "get_movie" path = "/get_movie"
you can access my git repo for file structure “GitHub - chinaza-max/netlify_severless”
Hi @chinaza-max , thanks for the post and welcome.
To create an edge function to deploy with your site, write a JavaScript or TypeScript file stored in your edge functions directory. The default edge functions directory is
YOUR_BASE_DIRECTORY/netlify/edge-functions
.
For example, create a function file atnetlify/edge-functions/hello.js
:
The above is quoted from the documentation at Get started with Edge Functions | Netlify Docs
Based on your repository that you shared your get_movie.js
is in a get_movie
directory.
Kindly move the get_movie.js
into the edge-functions
directory instead of get_movie
thanks it solve my problem . but it was autogenerated for me when i selected edge function
Now am testing the netlify function Am getting “Function not found…” on the browser am accessing it with http://localhost:8888/.netlify/functions/hello . this is a link to the proj git repo GitHub - chinaza-max/netlify_function_severless .
On the terminal am also seeing this message but am no longer using the edge function “» Warning: Could not process edge functions dependency graph. Live reload will not be available”.
Please can you also share me with a standard way of doing this thing becus becus after implementing this stuff according to netlify doc i still have issues and from the error message i cant even debug myself
Hi @chinaza-max , for Netlify Functions I recommend you read the blog post below as there has been an update to Netlify Functions recently.
For more information also visit the documentation page below
In addition change your code in the hello.js
file to the below
export default async (req, context) => {
return new Response("Hello, world!");
};
am currenly having this issues Error: Netlify CLI has terminated unexpectedly
This is a problem with the Netlify CLI, not with your application.
If you recently updated the CLI, consider reverting to an older version by running:
npm install -g netlify-cli@VERSION
You can use any version from Releases · netlify/cli · GitHub. i have tried this vesions /v17.8.1
//17.8.0
//17.7.0 of the netlify cli and it still persist . get this error when i run netlify dev
Hi @chinaza-max , thanks for the feedback
Kindly update your Netlify CLI to the version 17.9.0 (2023-12-04) to see if it works.
No am still getting the same issues this is my source code GitHub - chinaza-max/netlify_function_severless
You need to add typescript
to your dependencies. This is the entire log:
✘ [ERROR] Could not resolve "typescript"
node_modules/cosmiconfig/dist/loaders.js:62:29:
62 │ typescript = require('typescript');
╵ ~~~~~~~~~~~~
You can mark the path "typescript" as external to exclude it from the bundle, which will remove
this error and leave the unresolved path in the bundle. You can also surround this "require" call
with a try/catch block to handle this failure at run-time instead of bundle-time.
✘ [ERROR] Could not resolve "typescript"
node_modules/cosmiconfig/dist/loaders.js:91:35:
91 │ typescript = (await import('typescript')).default;
╵ ~~~~~~~~~~~~
You can mark the path "typescript" as external to exclude it from the bundle, which will remove
this error and leave the unresolved path in the bundle. You can also add ".catch()" here to handle
this failure at run-time instead of bundle-time.
◈ Failed to load function hello: Build failed with 2 errors:
node_modules/cosmiconfig/dist/loaders.js:62:29: ERROR: Could not resolve "typescript"
node_modules/cosmiconfig/dist/loaders.js:91:35: ERROR: Could not resolve "typescript"
› Error: Netlify CLI has terminated unexpectedly
This is a problem with the Netlify CLI, not with your application.
If you recently updated the CLI, consider reverting to an older version by running:
npm install -g netlify-cli@VERSION
You can use any version from https://ntl.fyi/cli-versions.
Please report this problem at https://ntl.fyi/cli-error including the error details below.
Error: Build failed with 2 errors:
node_modules/cosmiconfig/dist/loaders.js:62:29: ERROR: Could not resolve "typescript"
node_modules/cosmiconfig/dist/loaders.js:91:35: ERROR: Could not resolve "typescript"
at failureErrorWithLog (/home/hrishikesh/f-107259/node_modules/netlify-cli/node_modules/@netlify/zip-it-and-ship-it/node_modules/esbuild/lib/main.js:1649:15)
at /home/hrishikesh/f-107259/node_modules/netlify-cli/node_modules/@netlify/zip-it-and-ship-it/node_modules/esbuild/lib/main.js:1058:25
at runOnEndCallbacks (/home/hrishikesh/f-107259/node_modules/netlify-cli/node_modules/@netlify/zip-it-and-ship-it/node_modules/esbuild/lib/main.js:1484:45)
at buildResponseToResult (/home/hrishikesh/f-107259/node_modules/netlify-cli/node_modules/@netlify/zip-it-and-ship-it/node_modules/esbuild/lib/main.js:1056:7)
at /home/hrishikesh/f-107259/node_modules/netlify-cli/node_modules/@netlify/zip-it-and-ship-it/node_modules/esbuild/lib/main.js:1085:16
at responseCallbacks.<computed> (/home/hrishikesh/f-107259/node_modules/netlify-cli/node_modules/@netlify/zip-it-and-ship-it/node_modules/esbuild/lib/main.js:703:9)
at handleIncomingPacket (/home/hrishikesh/f-107259/node_modules/netlify-cli/node_modules/@netlify/zip-it-and-ship-it/node_modules/esbuild/lib/main.js:763:9)
at Socket.readFromStdout (/home/hrishikesh/f-107259/node_modules/netlify-cli/node_modules/@netlify/zip-it-and-ship-it/node_modules/esbuild/lib/main.js:679:7)
at Socket.emit (node:events:517:28)
at Socket.emit (node:domain:489:12)
System:
OS: Linux 5.15 Ubuntu 22.04.3 LTS 22.04.3 LTS (Jammy Jellyfish)
CPU: (16) x64 13th Gen Intel(R) Core(TM) i5-13500H
Binaries:
Node: 20.9.0 - ~/.asdf/installs/nodejs/20.9.0/bin/node
npm: 10.2.4 - ~/.asdf/plugins/nodejs/shims/npm
I was recently using Netlify CLI on Windows and noticed that the error is not shown in the terminal. You might want to use WSL.