具有托管功能的Azure静态Web应用程序找不到模块

发布于 2025-02-10 02:37:15 字数 1957 浏览 1 评论 0原文

我有一个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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文