在VSCode中使用Azure App Service扩展将NodeJS>typescript项目部署到Azure

wtlkbnrh  于 2023-04-29  发布在  Node.js
关注(0)|答案(1)|浏览(119)

我尝试使用VSCode扩展Azure APP Service将nodeJS,typescript项目部署到Azure部署插槽,但我收到以下错误:ENOENT: no such file or directory
我的项目树

我的package.json

{
  "name": "otj_server_app",
  "version": "1.0.0",
  "description": "",
  "main": "build/src/index.js",
  "scripts": {
    "build_typescript": "tsc",
    "build_local": "cp config/config_local.json config/config.json",
    "build_dev": "cp config/config_dev.json config/config.json",
    "build_sit": "cp config/config_sit.json config/config.json",
    "build_prod": "cp config/config_prod.json config/config.json",
    "start": "tsc && nodemon build/src/index.js",
    "clean": "rimraf build",
    "build": "npm run clean && tsc"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "dependencies": {
    "body-parser": "^1.20.0",
    "cors": "^2.8.5",
    "express": "^4.18.1",
    "express-session": "^1.17.3",
    "form-data": "^4.0.0",
    "formidable": "^2.0.1",
    "fs-extra": "^10.1.0",
    "https": "^1.0.0",
    "infosysta-typescript-core": "git+ssh://git@scm.infosysta.com:7999/ac/infosysta-typescript-core.git",
    "oauth": "^0.10.0",
    "random-string": "^0.2.0",
    "request-promise": "^4.2.6",
    "rimraf": "^5.0.0",
    "socket.io": "^2.4.1",
    "socket.io-client": "^2.3.0",
    "typescript": "^4.8.3"
  },
  "devDependencies": {
    "@types/cors": "^2.8.12",
    "@types/express": "^4.17.14",
    "@types/express-session": "^1.17.4",
    "nodemon": "^2.0.19"
  }
}

问题

我所尝试的

  • 我试图删除node_modules文件夹,package-lock.json运行npm install并重试,但没有成功
  • 我还试图强制删除缓存npm cache clean --force并再次执行步骤1,但也没有成功

有什么问题吗?

myzjeezk

myzjeezk1#

信息:“ENOENT:没有这样的文件或目录”
这通常表示应用程序试图访问的文件或目录不存在。这可能是因为文件路径不正确或缺少任何包,或者部署槽中缺少文件。
检查以下故障排除步骤是否有助于您解决问题。

  • 验证代码中的文件路径对于访问文件和目录是否有效,并检查文件或目录是否存在于应用程序尝试访问的路径中。

  • 通过在项目的根目录中运行npm install来验证是否安装了所有必需的包。

  • 在诊断中检查错误的详细信息并解决问题:

  • 我试图删除node_modules文件夹,package-lock.json运行npm install并再次尝试,但没有运气我还试图强制删除缓存npm cache clean --force并再次执行步骤1,但也没有运气

  • 尝试以下命令:

npm install
npm cache clean --force
npm install -g npm
npm install

然后删除node_modules文件夹和package-lock.json文件,然后运行npm install

  • 如果这些步骤都不起作用,请尝试创建一个新的部署插槽并将应用程序部署到新插槽中。这有时有助于解决部署过程中的问题。
  • 如果你正在部署Typescript Azure函数,我建议你更喜欢部署到函数应用程序而不是Web应用程序。当我试图将我的函数部署到Azure Web应用服务时,我也遇到了同样的错误。

  • 我已经从VS代码创建并部署了一个项目到Azure Web App服务。*

  • 应用程序已部署并在部署插槽中运行:*

    结果:

相关问题