【发布时间】:2019-07-21 08:43:04
【问题描述】:
我正在尝试将我的 NEXTJS 应用程序部署到 azure。
我创建了一个带有安装了 Node 的 linux 操作系统的 web 应用程序。
我的package.json 看起来像这样。
{
"name": "frontend",
"version": "1.0.0",
"description": "This package contains all necessary depenencies for frontned",
"main": "index.js",
"scripts": {
"dev": "next",
"build": "next build",
"start": "next start -p $PORT",
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "masnad",
"license": "ISC",
"dependencies": {
"@zeit/next-css": "^1.0.1",
"next": "^8.0.3",
"react": "^16.8.3",
"react-dom": "^16.8.3"
}
}
我首先创建了一个空的 web 应用程序,然后使用部署服务 kudu 将我的代码从本地推送到 azure。
推送到azure时的git日志是这样的
remote: ..............................................................
remote: npm WARN rollback Rolling back fsevents@1.2.7 failed (this is probably harmless): ENOTEMPTY: directory not empty, rmdir '/home/site/wwwroot/node_modules/fsevents/node_modules/abbrev'
remote: npm WARN rollback Rolling back rc@1.2.8 failed (this is probably harmless): ENOTEMPTY: directory not empty, rmdir '/home/site/wwwroot/node_modules/fsevents/node_modules/rc/node_modules/minimist'
remote:
remote: > ax-frontend@1.0.0 postinstall /home/site/wwwroot
remote: > next build
remote:
remote: ...............
remote: Creating an optimized production build ...
remote:
remote: ...
remote: Compiled successfully.
remote:
remote: ┌ /
remote: ├ /_app
remote: ├ /_document
remote: └ /_error
remote:
remote: npm WARN unistore@3.2.1 requires a peer of preact@* but none is installed. You must install peer dependencies yourself.
remote: audited 6645 packages in 139.904s
remote: found 0 vulnerabilities
remote: npm WARN ax-frontend@1.0.0 No repository field.
remote:
remote: npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.7 (node_modules/fsevents):
remote: npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.7: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
remote:
remote:
remote: > ax-frontend@1.0.0 build /home/site/wwwroot
remote: > next build
remote:
remote: .........
remote: Creating an optimized production build ...
remote:
remote: ...
remote: Compiled successfully.
remote:
remote: ┌ /
remote: ├ /_app
remote: ├ /_document
remote: └ /_error
remote:
remote:
remote: Done.
remote: Running post deployment command(s)...
remote: Deployment successful.
remote: App container will begin restart within 10 seconds.
To https://node-ax-dev.scm.azurewebsites.net:443/node-ax-dev.git
ec4d5ad..dcadc02 development -> master
所以我猜它部署得很好。
我去了https://node-ax-dev-1212.azurewebsites.net,但什么也没发生。
所以我在实例内部进行了 SSH,然后运行 npm run dev,它立即向我显示了在 localhost:3000 上运行的项目。
所以我写了https://node-ax-dev-1212.azurewebsites.net:3000,但它没有工作,因为它在终端中告知端口已在使用中并关闭。
我不确定出了什么问题,但感觉就像我正确地完成了大部分程序。
我没有添加任何特定的环境变量,所以一切都是全新的。 我的目录看起来像这样。
P.S 我还尝试在应用程序设置runtime 中添加启动文件命令npm run dev,但我认为它不起作用。
【问题讨论】:
标签: javascript node.js reactjs azure next.js