具有托管功能的Azure静态Web应用程序找不到模块
我有一个MonorePo,总共包含5个软件包:
- 前端
- 后端
- 库1
- 库2
- 库3
后端使用库。每当我模拟SWA时,一切都可以正常工作,但是每当我部署应用程序时,我都会获得错误:
Exception while executing function: Functions.npm-dependency-report Result: Failure
Exception: Worker was unable to load function npm-dependency-report: 'Cannot find module 'rimraf'
Require stack:
- /home/site/wwwroot/dist/npm-dependency-report/index.js
- /azure-functions-host/workers/node/dist/src/worker-bundle.js
- /azure-functions-host/workers/node/dist/src/nodejsWorker.js'
Stack: Error: Cannot find module 'rimraf'
Require stack:
- /home/site/wwwroot/dist/npm-dependency-report/index.js
- /azure-functions-host/workers/node/dist/src/worker-bundle.js
- /azure-functions-host/workers/node/dist/src/nodejsWorker.js
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
at Function.Module._load (node:internal/modules/cjs/loader:778:27)
at Module.require (node:internal/modules/cjs/loader:1005:19)
at Object.apply (/azure-functions-host/workers/node/dist/src/worker-bundle.js:2:38624)
at require (node:internal/modules/cjs/helpers:102:18)
at /home/site/wwwroot/dist/npm-dependency-report/index.js:279:5348
at /home/site/wwwroot/dist/npm-dependency-report/index.js:1:222
at /home/site/wwwroot/dist/npm-dependency-report/index.js:279:12306
at /home/site/wwwroot/dist/npm-dependency-report/index.js:1:222
at Object.<anonymous> (/home/site/wwwroot/dist/npm-dependency-report/index.js:283:1294)
安装了模块Rimraf并将其包含在后端的包装中。每当我删除使用RIMRAF的行时,它都会与另一个称为“ node-gyp”的依赖关系产生相同的错误,这甚至不是我项目的依赖性,而是我的一个依赖关系的依赖性。
我使用
命令用于模拟SWA:swa start -app-location ./packages/frontend-api-location ./packages/backend-backend-eactend-exend-put-location ./dist
用于部署SWA的命令:swa deploy -app-location ./packages/frontend -api-location ./packages/backend-backend-output-location ./dist
I have a monorepo that contains 5 packages in total:
- frontend
- backend
- library 1
- library 2
- library 3
The backend uses the libraries. Whenever I emulate the SWA everything works fine but whenever I deploy the application, I get the error:
Exception while executing function: Functions.npm-dependency-report Result: Failure
Exception: Worker was unable to load function npm-dependency-report: 'Cannot find module 'rimraf'
Require stack:
- /home/site/wwwroot/dist/npm-dependency-report/index.js
- /azure-functions-host/workers/node/dist/src/worker-bundle.js
- /azure-functions-host/workers/node/dist/src/nodejsWorker.js'
Stack: Error: Cannot find module 'rimraf'
Require stack:
- /home/site/wwwroot/dist/npm-dependency-report/index.js
- /azure-functions-host/workers/node/dist/src/worker-bundle.js
- /azure-functions-host/workers/node/dist/src/nodejsWorker.js
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
at Function.Module._load (node:internal/modules/cjs/loader:778:27)
at Module.require (node:internal/modules/cjs/loader:1005:19)
at Object.apply (/azure-functions-host/workers/node/dist/src/worker-bundle.js:2:38624)
at require (node:internal/modules/cjs/helpers:102:18)
at /home/site/wwwroot/dist/npm-dependency-report/index.js:279:5348
at /home/site/wwwroot/dist/npm-dependency-report/index.js:1:222
at /home/site/wwwroot/dist/npm-dependency-report/index.js:279:12306
at /home/site/wwwroot/dist/npm-dependency-report/index.js:1:222
at Object.<anonymous> (/home/site/wwwroot/dist/npm-dependency-report/index.js:283:1294)
The module rimraf is installed and included in the package.json of the backend. Whenever I remove the line that uses rimraf, it gives the same error with another dependency called 'node-gyp', which is not even a dependency of my project, but a dependency of one of my dependencies.
I deployed the application using Azure SWA CLI, and whatever I do, I cannot get rid of the error.
Command used to emulate the SWA: swa start --app-location ./packages/frontend --api-location ./packages/backend --output-location ./dist
Command used to deploy the SWA: swa deploy --app-location ./packages/frontend --api-location ./packages/backend --output-location ./dist
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论