azure - Azure Pipelines 上成功的节点构建无法在应用服务上启动 - 依赖问题
问题描述
尝试将我的节点项目迁移到 Azure。将我的源代码移至 Azure Repos 并设置 Azure Pipelines CI/CD。我的源通过测试、构建并部署到应用服务实例,但无法启动。
2019-04-13T11:17:11.727563855Z / _ \ __________ _________ ____
2019-04-13T11:17:11.741887486Z / /_\ \___ / | \_ __ \_/ __ \
2019-04-13T11:17:11.741914387Z / | \/ /| | /| | \/\ ___/
2019-04-13T11:17:11.741924187Z \____|__ /_____ \____/ |__| \___ >
2019-04-13T11:17:11.741932687Z \/ \/ \/
2019-04-13T11:17:11.741953688Z A P P S E R V I C E O N L I N U X
2019-04-13T11:17:11.741963888Z
2019-04-13T11:17:11.741971688Z Documentation: http://aka.ms/webapp-linux
2019-04-13T11:17:11.741979588Z NodeJS quickstart: https://aka.ms/node-qs
2019-04-13T11:17:11.741987288Z NodeJS Version : v10.14.1
2019-04-13T11:17:11.741995089Z
2019-04-13T11:17:12.114900305Z Generating app startup command
2019-04-13T11:17:12.139813980Z Found scripts.start in /home/site/wwwroot/package.json
2019-04-13T11:17:12.164269945Z Running npm --prefix=/home/site/wwwroot start
2019-04-13T11:17:13.701617867Z
2019-04-13T11:17:13.701678868Z > my-app-server@1.0.0 start /home/site/wwwroot
2019-04-13T11:17:13.701692968Z > NODE_ENV=production pm2 start server.js
2019-04-13T11:17:13.701701469Z
2019-04-13T11:17:14.489068461Z internal/modules/cjs/loader.js:582
2019-04-13T11:17:14.489134763Z throw err;
2019-04-13T11:17:14.489144863Z ^
2019-04-13T11:17:14.489152863Z
2019-04-13T11:17:14.489160663Z Error: Cannot find module '../constants.js'
2019-04-13T11:17:14.489168863Z at Function.Module._resolveFilename (internal/modules/cjs/loader.js:580:15)
2019-04-13T11:17:14.489177064Z at Function.Module._load (internal/modules/cjs/loader.js:506:25)
2019-04-13T11:17:14.489185164Z at Module.require (internal/modules/cjs/loader.js:636:17)
2019-04-13T11:17:14.489193164Z at require (internal/modules/cjs/helpers.js:20:18)
2019-04-13T11:17:14.489200964Z at Object. (/home/site/wwwroot/node_modules/.bin/pm2:11:20)
2019-04-13T11:17:14.489209464Z at Module._compile (internal/modules/cjs/loader.js:688:30)
2019-04-13T11:17:14.489217265Z at Object.Module._extensions..js (internal/modules/cjs/loader.js:699:10)
2019-04-13T11:17:14.489225365Z at Module.load (internal/modules/cjs/loader.js:598:32)
2019-04-13T11:17:14.489233165Z at tryModuleLoad (internal/modules/cjs/loader.js:537:12)
2019-04-13T11:17:14.533531589Z at Function.Module._load (internal/modules/cjs/loader.js:529:3)
2019-04-13T11:17:14.609360341Z npm ERR! code ELIFECYCLE
2019-04-13T11:17:14.651011003Z npm ERR! errno 1
2019-04-13T11:17:14.651070504Z npm ERR! may-app-server@1.0.0 start: `NODE_ENV=production pm2 start server.js`
2019-04-13T11:17:14.651096805Z npm ERR! Exit status 1
2019-04-13T11:17:14.651106405Z npm ERR!
2019-04-13T11:17:14.651114605Z npm ERR! Failed at the my-app-server@1.0.0 start script.
2019-04-13T11:17:14.651122906Z npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2019-04-13T11:17:14.679406459Z
2019-04-13T11:17:14.710652581Z npm ERR! A complete log of this run can be found in:
2019-04-13T11:17:14.710698082Z npm ERR! /root/.npm/_logs/2019-04-13T11_17_14_602Z-debug.log
YAML:
trigger:
- master
pool:
vmImage: 'Ubuntu-16.04'
steps:
- task: NodeTool@0
inputs:
versionSpec: '10.14.2'
displayName: 'Install Node.js'
- script: |
npm run init
displayName: 'install deps'
- script: |
npm run build
displayName: 'build frontend'
- task: ArchiveFiles@2
displayName: 'Archive files'
inputs:
rootFolderOrFile: 'backend/'
includeRootFolder: false
verbose: true
- task: PublishBuildArtifacts@1
displayName: 'Publish artifacts: drop'
我已经下载了工件并尝试在本地运行它们,但我得到了同样的错误。如果我重新安装依赖项,它将运行。
我在代理上设置了“10.14.1”和“Ubuntu-16.04”,并且应用服务器实例具有相同的节点版本,但 linux 版本不同(一般) - 这可能是原因吗?
另一方面,将构建的压缩node_modules
并复制过来似乎有点奇怪,这是 Azure 方式吗?
谢谢,E。
解决方案
推荐阅读
- reactjs - 覆盖 BaseWeb/baseui 选择标签
- javascript - 未捕获的 SyntaxError:意外的标记“类”
- javascript - Angular 应用程序上任何模型类的 Typescript 基础模型
- javascript - 如何使用 Vite 将入口点更改为默认的 'src/main.js' 以外的其他内容?
- r - 我如何更宽地旋转并按两列计算一对的出现?
- python - 使用 Python 和 PYODBC 从 SQL Server 数据库中检索数据
- perl - 如何检查模板工具包中的变量类型?
- python - 在 Freeswitch python 脚本中捕获 SIP“200 OK”
- mit-scratch - 用字符替换单词中的字母
- notepad++ - 将光标移动到当前屏幕的第一行或最后一行