Node.js 项目的 Azure Web 服务部署失败
Posted
技术标签:
【中文标题】Node.js 项目的 Azure Web 服务部署失败【英文标题】:Azure Web Service Deployment fails for Node.js project 【发布时间】:2021-09-07 04:27:06 【问题描述】:我在将 Vue.js 项目部署到 Azure Web 服务时遇到了一个奇怪的问题。首先要做的事情是:设置完美,我可以访问 Web 服务,我面临的唯一问题是部署失败。当我在本地使用 npm run serve
启动应用程序时,一切正常,但我收到大量错误,例如 82:18 Property 'load' does not exist on type 'Vue'.
。
我们暂时忽略了这些错误,因为存在负载并且我们可以正常使用它,但没有找到解决这些错误的解决方案。因此,问题是:这些错误(即使显示的错误正在标记我们使用的东西并且哪些有效)是否会使部署失败?
部署的最后一行如下:
2021-06-23T15:09:46.095Z - npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@2.3.1 (node_modules/webpack/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.3.1: wanted "os":"darwin","arch":"any" (current: "os":"linux","arch":"x64")
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.13 (node_modules/webpack-dev-server/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.13: wanted "os":"darwin","arch":"any" (current: "os":"linux","arch":"x64")
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.13 (node_modules/watchpack-chokidar2/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.13: wanted "os":"darwin","arch":"any" (current: "os":"linux","arch":"x64")
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@2.3.1 (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.3.1: wanted "os":"darwin","arch":"any" (current: "os":"linux","arch":"x64")
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@2.1.3 (node_modules/fork-ts-checker-webpack-plugin/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.1.3: wanted "os":"darwin","arch":"any" (current: "os":"linux","arch":"x64")
- Building for production...
ERROR Build failed with errors.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! project@0.1.0 build: `vue-cli-service build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the project@0.1.0 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/.npm/_logs/2021-06-23T15_09_29_048Z-debug.log
/opt/Kudu/Scripts/starter.sh oryx build /home/site/repository -o /home/site/wwwroot --platform nodejs --platform-version 14 -i /tmp/8d93658061b46ee -p compress_node_modules=tar-gz --log-file /tmp/build-debug.log
老实说,我不知道如何处理这个巨大的错误。我搜索了一下,但没有找到合适的解决方案。
我尝试在本地运行npm run build
(谢谢@polmonite),我在 npm 缓存中的错误日志现在看起来像这样:
0 info it worked if it ends with ok
1 verbose cli [ 'C:\\Program Files\\nodejs\\node.exe',
1 verbose cli 'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli 'run',
1 verbose cli 'build' ]
2 info using npm@6.4.1
3 info using node@v8.12.0
4 verbose run-script [ 'prebuild', 'build', 'postbuild' ]
5 info lifecycle myProject@0.1.0~prebuild: myProject@0.1.0
6 info lifecycle myProject@0.1.0~build: myProject@0.1.0
7 verbose lifecycle myProject@0.1.0~build: unsafe-perm in lifecycle true
8 verbose lifecycle myProject@0.1.0~build: PATH: C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin;C:\Users\***\node_modules\.bin;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files\Git\cmd;C:\Program Files\dotnet\;C:\Program Files\nodejs\;C:\WINDOWS\System32\OpenSSH\;C:\Program Files\Intel\WiFi\bin\;C:\Program Files\Common Files\Intel\WirelessCommon\;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Microsoft SQL Server\130\Tools\Binn\;C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\170\Tools\Binn\;C:\Program Files\CMake\bin;C:\Users\***\AppData\Local\Programs\Python\Python39\Scripts\;C:\Users\***\AppData\Local\Programs\Python\Python39\;C:\Users\***\AppData\Local\Microsoft\WindowsApps;C:\Users\***\AppData\Roaming\npm;C:\Users\***\.dotnet\tools;C:\Users\***\AppData\Local\Microsoft\WindowsApps;C:\Users\***\.dotnet\tools;C:\Users\***\AppData\Local\Programs\Microsoft VS Code\bin;
9 verbose lifecycle myProject@0.1.0~build: CWD: C:\Users\***\myProject
10 silly lifecycle myProject@0.1.0~build: Args: [ '/d /s /c', 'vue-cli-service build' ]
11 silly lifecycle myProject@0.1.0~build: Returned: code: 1 signal: null
12 info lifecycle myProject@0.1.0~build: Failed to exec build script
13 verbose stack Error: myProject@0.1.0 build: `vue-cli-service build`
13 verbose stack Exit status 1
13 verbose stack at EventEmitter.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\index.js:301:16)
13 verbose stack at emitTwo (events.js:126:13)
13 verbose stack at EventEmitter.emit (events.js:214:7)
13 verbose stack at ChildProcess.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\lib\spawn.js:55:14)
13 verbose stack at emitTwo (events.js:126:13)
13 verbose stack at ChildProcess.emit (events.js:214:7)
13 verbose stack at maybeClose (internal/child_process.js:915:16)
13 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)
14 verbose pkgid myProject@0.1.0
15 verbose cwd C:\Users\***\Git\myProject
16 verbose Windows_NT 10.0.19042
17 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run" "build"
18 verbose node v8.12.0
19 verbose npm v6.4.1
20 error code ELIFECYCLE
21 error errno 1
22 error myProject@0.1.0 build: `vue-cli-service build`
22 error Exit status 1
23 error Failed at the myProject@0.1.0 build script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]
【问题讨论】:
这可能是由于依赖。你检查 kudu 了吗? 当我检查 Kudu 中的最新部署时,部署状态为3
,状态文本为空。我在日志流中找不到任何其他内容。但是在我看到的 Azure 门户的Deployment center
中,部署停止在`Running oryx build...
。 “停止”的意思是:状态已经停留在这个状态一个多月了。日志的最后一部分是- Building for production... Starting type checking service... Using 1 worker with 2048MB memory limit
我刚刚开始(20分钟前)一个新的部署任务,但它仍然是pending
。
正如我在上面发布的回复一样,部署任务失败并显示完全相同的错误消息,我在问题中发布。
可能是一个愚蠢的问题:如果您在本地启动npm run build
(或vue-cli-service build
)而不是启动npm run serve
,您会得到同样的错误吗?
您检查过this SO 的问题吗?如果您使用的是打字稿,那么它很可能与您在使用load
时遇到的问题相同。关于fsevents
的警告,应该不是问题:请看this GitHub issue。
【参考方案1】:
我也遇到过类似的问题,这可能对您没有帮助,但是您检查过您的应用服务计划的容量吗?如果您使用的是免费层(1GB 可用内存),那么您的项目大小(当然包括 node_modules)不应超过 1GB 限制。
【讨论】:
我构建的项目的大小约为 250MB,所以我不认为这是问题所在。以上是关于Node.js 项目的 Azure Web 服务部署失败的主要内容,如果未能解决你的问题,请参考以下文章
Azure Web 应用 Node.js 部署后返回 404
是否有人成功使用 Azure AD 对 Node.js Web 应用程序的用户进行身份验证?
Azure Web App-当您选择Runtime stack作为Node.js时,为什么只让您选择Linux作为操作系统?