[英]Error: Cannot find module '/workspace/server.js' upon node js deploy on google app engine
After a week of searching, I am not able to find a solution for an app engine deploy issue for my node.js application.经过一周的搜索,我无法为我的 node.js 应用程序找到应用引擎部署问题的解决方案。
I have come to the point that I have replaced my original code with this "hello world" example for express .我已经到了用express 的这个“hello world”示例替换我的原始代码的地步。 Running this in my local dev environment offline works well (as expected).
在我的本地开发环境中离线运行它效果很好(如预期)。
Then I deploy this app to my google app engine project online using the gcloud cli.然后我使用 gcloud cli 将这个应用程序在线部署到我的谷歌应用程序引擎项目。 That seems to work as well (no errors).
这似乎也有效(没有错误)。
However, when I visit the app online, instead of seeing my app, I see a black page with this message: "Error: Server Error The server encountered an error and could not complete your request. Please try again in 30 seconds.".但是,当我在线访问该应用程序时,我没有看到我的应用程序,而是看到一个黑色页面,其中包含以下消息:“错误:服务器错误服务器遇到错误,无法完成您的请求。请在 30 秒后重试。”。 After some digging in the google cloud console logs, I find that the error seems to be "Error: Cannot find module '/workspace/server.js'" (see more info here ).
在谷歌云控制台日志中进行一些挖掘后,我发现错误似乎是“错误:找不到模块‘/workspace/server.js’”(更多信息参见此处)。 I do not use such a module myself, nor do I define such a path in any of my files.
我自己不使用这样的模块,也不在我的任何文件中定义这样的路径。
Does anyone have an idea what might be going wrong and how I can fix it?有谁知道可能出了什么问题以及我该如何解决? I have deployed apps successfully recently, but I'm at a loss here...
我最近成功部署了应用程序,但我在这里不知所措......
In my case, I got carried away with my .gcloudignore
file就我而言,我被我的
.gcloudignore
文件冲昏了头脑
I used .gcloudignore
to ignore directories like bin
, but I forgot that bin
contained the file www
which was the file run by my package.json
"scripts">"start"我用
.gcloudignore
忽略像bin
这样的目录,但我忘记了bin
包含文件www
这是我的package.json
"scripts">"start" 运行的文件
{
"name": "craft",
"version": "0.0.0",
"private": true,
"scripts": {
"start": "node ./bin/www",
...
If .gcloudignore
ignores a directory, that directory is not deployed to Google App Engine, therefore I got the error:如果
.gcloudignore
忽略目录,则该目录不会部署到 Google App Engine,因此我收到错误:
Cannot find module '/workspace/bin/www'
So the solution was to stop ignoring certain files.所以解决方案是停止忽略某些文件。
I know this is not the solution for the OP (OP says they needed changes to their app.yaml
handlers ) but it may help other people!我知道这不是 OP 的解决方案(OP 说他们需要更改他们的
app.yaml
处理程序)但它可能会帮助其他人!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.