简体   繁体   English

Google App Engine - 部署 nodejs 应用程序时缺少目录

[英]Google App Engine - Directory missing on deploying nodejs app

I have a nodejs web app (based on koa.js) that is written in Typescript and I want to deploy it on Google App Engine.我有一个用 Typescript 编写的 nodejs Web 应用程序(基于 koa.js),我想将它部署在 Google App Engine 上。

The code is already transpiled to JavaScript and is located locally in ./dist/src/ .代码已经转换为 JavaScript 并位于本地./dist/src/

So basically I want to deploy only ./package.json and ./dist/src/ .所以基本上我只想部署./package.json./dist/src/

My app.yaml:我的 app.yaml:

runtime: nodejs12
service: my-first-service
env_variables:
  somekey: somevalue

The start command in package.json: node --require dotenv/config ./dist/src/App.js package.json 中的启动命令: node --require dotenv/config ./dist/src/App.js

Uploading the app works fine.上传应用程序工作正常。 But it seems like the dist folder is missing.但似乎缺少 dist 文件夹。 In the logs I can see Error: Cannot find module '/srv/dist/src/App.js' .在日志中,我可以看到Error: Cannot find module '/srv/dist/src/App.js' Also in Stackdriver (debugging) I can't see the dist folder.同样在 Stackdriver(调试)中,我看不到 dist 文件夹。

The dist folder is part of my .gitignore but not in .gcloudignore . dist 文件夹是我的.gitignore一部分,但不在.gcloudignore

My .gcloudignore:我的 .gcloudignore:

.env
.gitcommittemplate
.git
.gitignore
.gitlab-ci.yml
googleCloudKey.json
*.log
*.md
tsconfig.json
tslint.json

.nyc_output/
.vscode/
cli/
dist/tests/
node_modules/
src/
tests/

I see that you included src/ folder in .gcloudignore .我看到您在.gcloudignore包含了src/文件夹。

This is the reason why your /dist/src/ is missing link .这就是您的 /dist/src/ 缺少链接的原因

For example, a pattern doc/frotz/ matches doc/frotz directory, but not a/doc/frotz directory;例如,模式 doc/frotz/ 匹配 doc/frotz 目录,但不匹配 /doc/frotz 目录; however frotz/ matches frotz and a/frotz that is a directory (all paths are relative from the .gitignore file).然而 frotz/ 匹配 frotz 和 a/frotz 是一个目录(所有路径都是相对于 .gitignore 文件的)。

I tested on my machine and got the same results.我在我的机器上测试并得到了相同的结果。 When I added src folder to my .gcoudignore file, both src/ and dist/src were ignored.当我将src文件夹添加到我的.gcoudignore文件时, src/dist/src都被忽略了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM