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.
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
Looks like I failed to build before deploying:
I need to run this first:
Then a
dist
folder will be generated after the build.Then I can do the deploying steps, and the function would appear.
I followed the given MS DOC and I can able to deploy my function to funtion app.
My function runs successfully locally as below,
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:-
The function got deployed successfully to the function app at Azure Portal as below,
The code runs successfully at Azure Portal also as below,
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,
Below is my package.json file,
package.json:
Run the below commands and try again,
Then try to run your code with fn+f5 and deploy that to function app.