简体   繁体   English

错误:在谷歌应用引擎上部署 node.js 后找不到模块“/workspace/server.js”

[英]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...我最近成功部署了应用程序,但我在这里不知所措......

As Cadet pointed out correctly, the solution was to make some changes to my app.yaml file.正如 Cadet 正确指出的那样,解决方案是对我的 app.yaml 文件进行一些更改。

This page allowed me to find the needed handlers. 这个页面让我找到了需要的处理程序。

Thanks a lot, Cadet.非常感谢,学员。

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.

相关问题 找不到模块 workspace/server.js - could not find module workspace/server.js 找不到 package.json。 Node.js 可能有启动问题。 验证 package.json 是否有效或将代码放在名为 server.js 或 app.js 的文件中 - Failed to find package.json. Node.js may have issues starting. Verify package.json is valid or place code in a file named server.js or app.js 谷歌云/应用引擎(节点 JS)“错误:EIO:i/o 错误,读取” - Google Cloud / App Engine (Node JS) "Error: EIO: i/o error, read" Firebase 节点 js 错误:无法理解要部署/服务的目标 - Firebase node js Error: Cannot understand what targets to deploy/serve App Engine Node.js 错误:排队的消息太多 - App Engine Node.js Error: Too many messages queued 出现错误:找不到模块“js-yaml” - Getting Error: Cannot find module 'js-yaml' Vue3.js )错误:找不到模块'firebase' - Vue3.js ) Error: Cannot find module 'firebase' Meteor JS框架兼容Google App Engine吗? - Is the Meteor JS framework compatible with Google App Engine? 无法从 App Engine 中的 Node JS 连接到 Cloud MySQL - Unable to connect to Cloud MySQL from Node JS in App Engine FIrebase 部署错误:找不到模块“firebase-admin” - FIrebase deploy error: Cannot find module 'firebase-admin'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM