【问题标题】:npm run start results in blank page only on Servernpm run start 仅在服务器上导致空白页
【发布时间】:2019-10-17 01:36:45
【问题描述】:

我刚刚在我的 Mac 上安装了一个 vue 登陆页面。终端到文件夹并正在运行“npm install”和“npm run dev”,它工作得很好。

但在托管服务器上 npm install 有时只是因为它经常被代码 137 杀死。我为项目文件夹创建了一个子域。

运行 npm run start 没有给我任何错误,但 url “subdomain.domain.legal” 在空白页中返回。主要没有被任何东西取代。端口 8080 给出“网站不可用”

您知道托管服务器上的哪些规格或设置可能有问题吗?

index.js

'use strict'
// Template version: 1.3.1
// see http://vuejs-templates.github.io/webpack for documentation.

const path = require('path')
module.exports = {
  dev: {

    // Paths
    assetsSubDirectory: 'static',
    assetsPublicPath: '/',
    proxyTable: {},

    // Various Dev Server settings
    host: 'subdomain.domain.legal', // can be overwritten by process.env.HOST
    port: 8080, // can be overwritten by process.env.PORT, if port is in use, a free one will be determined
    autoOpenBrowser: true,
    errorOverlay: true,
    notifyOnErrors: true,
    poll: false, // https://webpack.js.org/configuration/dev-server/#devserver-watchoptions-

    // Use Eslint Loader?
    // If true, your code will be linted during bundling and
    // linting errors and warnings will be shown in the console.
    useEslint: true,
    // If true, eslint errors and warnings will also be shown in the error overlay
    // in the browser.
    showEslintErrorsInOverlay: false,

    /**
     * Source Maps
     */

    // https://webpack.js.org/configuration/devtool/#development
    devtool: 'cheap-module-eval-source-map',

    // If you have problems debugging vue-files in devtools,
    // set this to false - it *may* help
    // https://vue-loader.vuejs.org/en/options.html#cachebusting
    cacheBusting: true,

    cssSourceMap: true
  },

npm run start 后出错(有时)

 I  Your application is running here: http://subdomain.domain.legal:8080                                        Killed
npm ERR! code ELIFECYCLE
npm ERR! errno 137
npm ERR! tovo_vue@1.0.0 dev: `webpack-dev-server --inline --progress --config build/webpack.dev.conf.js`
npm ERR! Exit status 137
npm ERR!
npm ERR! Failed at the tovo_vue@1.0.0 dev script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /usr/home/user/.npm/_logs/2019-05-31T11_47_21_305Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 137
npm ERR! tovo_vue@1.0.0 start: `npm run dev`
npm ERR! Exit status 137
npm ERR!
npm ERR! Failed at the tovo_vue@1.0.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /usr/home/user/.npm/_logs/2019-05-31T11_47_21_313Z-debug.log

(空白)页面的 HTML 代码

<html><head>
    <title>Title</title>
    <meta charset="utf-8">
    <meta name="author" content="pixelstrap">
    <meta name="description" content="xy">
    <meta name="keywords" content="xy">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <!-- Fav icon -->
    <link rel="shortcut icon" hre="/static/favicon.png">
    <!-- Font Family-->
    <link href="https://fonts.googleapis.com/css?family=Poppins:300,400,500,600,700" rel="stylesheet">
  </head>
  <body id="nav-scroller" data-spy="scroll" data-target=".navbar" data-offset="0">

  <div id="app"></div>


</body></html>

免费 -g:

              total        used        free      shared  buff/cache   available
Mem:             31           7          10           0          12          22
Swap:             3           0           3

ps 辅助 | grep 节点

user 1422  0.0  0.0  16712   968 pts/1    S+   14:18   0:00 grep node

【问题讨论】:

  • 我们需要看到的不仅仅是这些。代码 137 表示该进程从外部获得了 SIGKILL
  • 是的,我实际上是编码新手,所以请告诉我所有内容,我会尽快添加!
  • 在某处上传/usr/home/user/.npm/_logs/2019-05-31T11_47_21_313Z-debug.log。通常,此问题与 oomkiller 有关,但有了 10GB 的可用 RAM,这里还有其他问题。

标签: javascript vue.js npm


【解决方案1】:

一旦杀死一切,然后在代码下方重新开始。

 ps aux | grep node
 sudo kill -9 

还有,

sudo lsof -i:<PORT_NO>

暂时关闭实例,但无法在后台停止进程。所以有一次,

sudo kill <PID>

有效,但是当我们更新代码并保存时,再次出现这个问题,就像 Nodemon 一样。

所以退出终端就可以解决问题了。或

killall -9 node

【讨论】:

  • 您好,感谢您的回答!不幸的是,在我们的托管服务器上,我无权访问 sudoers 文件。我添加了 ps aux | 的输出。 grep 节点到我的帖子!
  • 您对与内存不足相关的SIGKILL 的解决方案是不分青红皂白地杀死所有节点进程,无论它们是什么或它们正在运行什么?如果它不是开发机器,这听起来像是自找麻烦。考虑您的建议对人们的影响。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2022-01-18
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-12-23
  • 2019-12-27
相关资源
最近更新 更多