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 I got while creating 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 follows.

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;

I got this error.

You can see the error message below

cannot find module '@azure/msal-browser' 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]

To fix this, I have downgraded the Azure Functions Core Tools version from Version V3 to Version V2.

I have run 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

Once I have installed this, you can see that the error is gone, and I can run the typescript Azure Function successfully without any issues.

Here is the output

cannot find module '@azure/msal-angular' or its corresponding type declarations.

This is how you can 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.

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

This will fix the error that Azure Functions cannot find module.

You may also like following the articles below

Wrapping Up

In this article, we discussed how to fix the error Cannot Find Module ‘@azure/functions’ or its Corresponding Type Declarations, Azure Functions Cannot Find Module. I hope you have enjoyed this article !!!