skip to Main Content

I followed the deployment guide precisely here https://learn.microsoft.com/en-us/azure/azure-functions/functions-develop-vs-code?tabs=nodejs#republish-project-files

However, After deploying, In Azure portal, there is no functions in function app.

enter image description here

And in the output log in VS code:

- /Users/myapp/code/test-azure-functions/node_modules/rimraf/dist/cjs/src/bin.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:885:15)
    at Function.Module._load (internal/modules/cjs/loader.js:730:27)
    at Module.require (internal/modules/cjs/loader.js:957:19)
    at require (internal/modules/cjs/helpers.js:88:18)
    at Object.<anonymous> (/Users/myapp/code/test-azure-functions/node_modules/minipass/dist/cjs/index.js:13:23)
    at Module._compile (internal/modules/cjs/loader.js:1068:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1097:10)
    at Module.load (internal/modules/cjs/loader.js:933:32)
    at Function.Module._load (internal/modules/cjs/loader.js:774:14)
    at Module.require (internal/modules/cjs/loader.js:957:19) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/Users/myapp/code/test-azure-functions/node_modules/minipass/dist/cjs/index.js',
    '/Users/myapp/code/test-azure-functions/node_modules/path-scurry/dist/cjs/index.js',
    '/Users/myapp/code/test-azure-functions/node_modules/glob/dist/cjs/src/glob.js',
    '/Users/myapp/code/test-azure-functions/node_modules/glob/dist/cjs/src/index.js',
    '/Users/myapp/code/test-azure-functions/node_modules/rimraf/dist/cjs/src/index.js',
    '/Users/myapp/code/test-azure-functions/node_modules/rimraf/dist/cjs/src/bin.js'
  ]
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] clean: `rimraf dist`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] clean script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

I have completely no clue now.
What should I do?

2

Answers


  1. Chosen as BEST ANSWER

    Looks like I failed to build before deploying:

    I need to run this first:

    npm run-scripts build
    

    Then a dist folder will be generated after the build.

    Then I can do the deploying steps, and the function would appear.


  2. I followed the given MS DOC and I can able to deploy my function to funtion app.

    My function runs successfully locally as below,

    enter image description here

    In order to use Azure Function Core tools command to deploy the Function like below:-

    Open your Vs Code terminal and run the commands below:-

    az login
    az account set --subscription "subsription-name"
    func azure functionapp publish functionapp-name
    

    enter image description here

    enter image description here

    The function got deployed successfully to the function app at Azure Portal as below,

    enter image description here

    The code runs successfully at Azure Portal also as below,

    enter image description here

    Coming to your error code, Some times, there might be corruption in the node_modules directory. To fix this, delete the “node_modules” folder and reinstall all dependencies.

    You can try the below command to install node_modules,

    npm install rimraf --save-dev
    

    Below is my package.json file,

    package.json:

    {
      "name": "your-project-name",
      "version": "1.0.0",
      "description": "",
      "scripts": {
        "start": "func start",
        "test": "echo "No tests yet..."",
        "clean": "rimraf dist"
      },
      "devDependencies": {
        "rimraf": "^5.0.1"
      }
    }
    

    Run the below commands and try again,

    npm install
    

    Then try to run your code with fn+f5 and deploy that to function app.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search