调整安装后脚本后,Heroku构建失败

时间:2018-01-04 13:44:21

标签: node.js heroku webpack post-install

我正在研究Heroku项目的拉取请求我遇到了以下问题:

  
    

- - - - >删除1个匹配.slugignore模式的文件。     ----->检测到Node.js应用     ----->创建运行时环境

  
   NPM_CONFIG_LOGLEVEL=error
   NPM_CONFIG_PRODUCTION=false
   NODE_VERBOSE=false
   NODE_ENV=production
   NODE_MODULES_CACHE=true
     

- - - - >安装二进制文件          engines.node(package.json):9.3.0          engines.npm(package.json):5.5.1

   Resolving node version 9.3.0...
   Downloading and installing node 9.3.0...
   npm 5.5.1 already installed with node
     

- - - - >恢复缓存          从cacheDirectories加载2(默认):           - node_modules           - bower_components(未缓存 - 跳过)   ----->构建依赖项          安装节点模块(package.json)   uglifyjs-webpack-plugin@0.4.6 postinstall / tmp / build_0205c32fc162b04a5bd36ce6d3e2a31a / GithubUsername-projName-45f1019 / node_modules / webpack / node_modules / uglifyjs-webpack-plugin   node lib / post_install.js   projName@0.3.0 postinstall / tmp / build_0205c32fc162b04a5bd36ce6d3e2a31a / GithubUserName-projName-45f1019   webpack -p --config ./webpack.config.js --progress

  90% chunk assets pro       Version: webpack 3.10.0
   Time: 25301ms
   Asset       Size  Chunks                    Chunk Names
  ///All chunk files emitted details
   projname.js    1.27 MB       0  [emitted]  [big]  main
   favicon.ico      17 kB          [emitted]
   index.html    37.4 kB          [emitted]
   [14] ./src/script.js 3.92 kB {0} [built]
   //built details
   + 208 hidden modules

   ERROR in ./src/assetLoader.js
   Module not found: Error: Can't resolve './manifest' in '/tmp/build_0205c32fc162b04a5bd36ce6d3e2a31a/GithubUsername-projName-45f1019/src'
   @ ./src/assetLoader.js 1:0-34
   @ ./src/game.js
   @ ./src/script.js

   ERROR in proj.js from UglifyJs
   Unexpected token: name (Creature) [GithubUsername-projName.js:1,99245]
   Child html-webpack-plugin for "index.html":
   Asset     Size  Chunks                    Chunk Names

   [2] ./node_modules/html-webpack-plugin/lib/loader.js!./src/index.html 
     

[内置]          [4](webpack)/buildin/global.js 509字节{0} [已建]          [5](webpack)/buildin/module.js 517字节{0} [已建]          [6] ./assets/interface/AB.gif 82字节{0} [建]          [7] ./assets/interface/ProjPage.png 82字节{0} [已建]          错误的ERR!代码ELIFECYCLE          错误的ERR!错误2          错误的ERR! projName@0.3.0 postinstall:webpack -p --config ./webpack.config.js --progress          错误的ERR!退出状态2          错误的ERR!          错误的ERR! projName@0.3.0 postinstall脚本失败。          错误的ERR!这可能不是npm的问题。上面可能有额外的日志记录输出。

   npm ERR! A complete log of this run can be found in:
   npm ERR!     /app/.npm/_logs/2018-01-03T13_35_09_304Z-debug.log
     

- - - - >构建失败

   We're sorry this build is failing! You can troubleshoot common issues here:
   https://devcenter.heroku.com/articles/troubleshooting-node-deploys

   If you're stuck, please submit a ticket so we can help:
   https://help.heroku.com/

   Love,
   Heroku
     !     Push rejected, failed to compile Node.js app.  !     Push failed

这里是代码:

package.json的片段

{
    "dependencies": {
        "compression": "^1.6.2",
        "express": "^4.13.4",
        "html-webpack-plugin": "^2.30.1",
        "jquery": "1.12.4",
        "jquery-mousewheel": "3.1.13",
        "jquery-ui": "^1.12.1",
        "jquery.kinetic": "2.2.4",
        "jquery.transit": "0.9.12",
        "phaser-ce": "2.7.10",
        "socket.io": "^1.3.5",
        "socket.io-client": "1.3.5"
    },
    "devDependencies": {
        "css-loader": "^0.28.7",
        "eslint": "^4.12.1",
        "expose-loader": "^0.7.4",
        "extract-text-webpack-plugin": "^3.0.2",
        "file-loader": "^1.1.5",
        "less": "^2.7.3",
        "less-loader": "^4.0.5",
        "prettier": "^1.8.2",
        "style-loader": "^0.19.0",
        "uglifyjs-webpack-plugin": "^1.1.2",
        "webpack": "^3.8.1",
        "webpack-merge": "^4.1.1"
    },

    "scripts": {
        "start": "node server.js",
        "postinstall": "webpack -p --config ./webpack.config.js --progress",
        "build": "yarn run generateManifest && webpack --env.production",
        "build:dev": "yarn run generateManifest && webpack",
        "dev": "webpack --watch",
        "lint": "eslint src/**/*.js",
        "generateManifest": "node manifestGenerator.js"
    }
}

Server.js

// Setup basic express server
var compression = require('compression');
var express = require('express');
var app = express();
var server = require('http').createServer(app);
var io = require('socket.io')(server);
var port = process.env.PORT || 8080;
var ip = process.env.IP || '127.0.0.1';
var gameManager = require('./server/gamemanager.js');
var qManager = require('./server/queuemanager.js');

// Setup the game queue and connection details
io.on('connection', function(session) {
    console.log('a user connected');

    // Store the username in the socket session for this client
    var username = makeid();
    session.username = username;

    // Add user to the queue
    qManager.addToQueue(session);

    session.on('disconnect', function() {
        console.log('user disconnected');
        qManager.removeFromQueue(session);
    });

    // Send user the username
    session.emit('login', session.username);

});


// Listen for server, and use static routing for deploy directory
server.listen(port, function() {
    console.log('Server listening at port %d', port);
});

app.use(express.static('./deploy', {
    maxAge: 86400000
}));

webpack.config.js代码

 const path = require('path');
const webpack = require('webpack');
const merge = require('webpack-merge');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const UglifyJSPlugin = require('uglifyjs-webpack-plugin');

// Are we in production
const production = process.env.production;

const baseSettings = {
    entry: path.resolve(__dirname, 'src', 'script.js'),
    output: {
        path: path.resolve(__dirname, 'deploy/'),
        filename: 'projname.js'
    },
    module: {
        rules: [
            {
                test: /\.less$/,
                use: [
                    'style-loader',
                    'css-loader',
                    'less-loader',
                ]
            },
            {
                test: /\.css$/,
                use: [
                    'style-loader',
                    'css-loader',
                ]
            },
            {
                test: /\.(png|jpg|gif|svg|ogg|ico|cur|woff|woff2)$/,
                use: [
                    'file-loader'
                ]
            }
        ]
    },
    resolve: {
        alias: {
            assets: path.resolve(__dirname, 'assets/'),
            modules: path.join(__dirname, "node_modules")
        }
    },
    plugins: [
        new HtmlWebpackPlugin({
            template: path.resolve(__dirname, 'src', 'index.html'),
            favicon: path.resolve(__dirname, 'assets', 'favicon.ico')
        }),
    ]
}

const prodSettings = {
    plugins: [
        new UglifyJSPlugin(),
        new webpack.DefinePlugin({
            'process.env.NODE_ENV': JSON.stringify('production')
        })
    ]
}

const devSettings = {
    devtool: 'cheap-module-eval-source-map'
}

// Create either a production or development build depending on the `production` env setting
module.exports = merge(baseSettings, production ? devSettings : prodSettings);

我无法理解Web包的问题是我的postinstall脚本出了什么问题?我在调整脚本时是否缺少任何规则?

我尝试应用来自SO和Heroku文档的一些解决方案,但没有任何工作......请帮助! 先感谢您!!! 随意评论任何其他信息。!!!

0 个答案:

没有答案