Cannot Find Module ‘@azure/functions’ or its Corresponding Type Declarations

In this Azure tutorial, we will discuss how to fix the error, Cannot Find Module ‘@azure/functions’ or its Corresponding Type Declarations that I got while trying to create a typescript Azure function using Visual Studio Code IDE.

Cannot Find Module ‘@azure/functions’ or its Corresponding Type Declarations

Recently, I was working with a requirement where I was trying to create a typescript Azure Function using the Visual Studio Code IDE. After creating the typescript Azure Function, I got the error “Cannot Find Module ‘@azure/functions’ or its Corresponding Type Declarations“.

The Azure Function code was as below.

import { AzureFunction, Context, HttpRequest } from "@azure/functions"

const httpTrigger: AzureFunction = async function (context: Context, req: HttpRequest): Promise<void> {
    context.log('HTTP trigger function processed a request.');
    const name = (req.query.name || (req.body && req.body.name));
    const responseMessage = name
        ? "Hello, " + name + ". This HTTP triggered function executed successfully."
        : "This HTTP triggered function executed successfully. Pass a name in the query string or in the request body for a personalized response.";

    context.res = {
        // status: 200, /* Defaults to 200 */
        body: responseMessage
    };

};

export default httpTrigger;

On the first line itself, I got the error Cannot Find Module ‘@azure/functions’ or its Corresponding Type Declarations.

You can able to see the error message as below

Cannot Find Module ‘azure functions or its Corresponding Type Declarations

The complete error message was as below

Cannot Find Module ‘@azure/functions’ or its Corresponding Type Declarations

Now, we will see how to fix the error.

Cannot Find Module ‘@azure/functions’ or its Corresponding Type Declarations [Solved]

Now to fix this, what I have done is, I have downgraded the Azure Functions Core Tools version from Version V3 to Version V2.

I have ran the below npm command to install the Azure Functions Core Tools in the Visual Studio Code terminal.

npm i -g azure-functions-core-tools@2 --unsafe-perm true

Now, once I have installed this, you can able to see, the error is gone now and I can able to run the typescript Azure Function successfully without any issue.

Here is the output

Cannot Find Module '@azure/functions'

This is how you can able to fix the error Cannot Find Module ‘@azure/functions’ or its Corresponding Type Declarations.

Azure Functions Cannot Find Module

If you are working with the  azure-functions-core-tools@1.0.10, there might be a chance of getting the error Azure Functions cannot find module.

Now, if you are getting the same error, to fix the issue, you need to downgrade the Azure Function core tools version to azure-functions-core-tools@1.0.9.

This will fix the error Azure Functions cannot find module.

You Must Have Azure functions Core Tools Installed

While working with Azure Function I got the error You Must Have Azure functions Core Tools Installed. There I have created Azure Function using Visual Studio Code. When I was trying to run the Azure Function, I got the error You Must Have Azure functions Core Tools Installed.

You can see below for the error details

You Must Have Azure functions Core Tools Installed

The complete error message was as below

You Must Have Azure functions Core Tools Installed to debug your local functions.

You Must Have Azure functions Core Tools Installed [Solved]

Now, to fix this issue, you need to click on the Install on the above popup button to install the Azure Function Core Tools.

There is a possibility, you might get few errors after clicking on the Install button, Now if you are getting any error, you can check out Azure Function Core Tool Not Installing on VS Code to fix the error.

This is how you can able to fix the error You Must Have Azure functions Core Tools Installed to debug your local functions.

npm install azure functions-core-tools 3

You can open a new terminal in Visual Studio Code and run the below cmdlet to install the azure functions-core-tools version 3.

npm install -g azure-functions-core-tools@3

If you are getting any issue with the above cmdlet, you can run the below cmdlet again to install the azure functions-core-tools version 3.

npm install -g azure-functions-core-tools@3 --force

You may also like following the below articles

Wrapping Up

Well, in this article, we have discussed how to fix the error Cannot Find Module ‘@azure/functions’ or its Corresponding Type Declarations, Azure Functions Cannot Find Module, You Must Have Azure functions Core Tools Installed, npm install azure functions-core-tools 3. Hope you have enjoyed this article !!!