vue.js - 托管应用程序后 npm run production 不起作用

标签 vue.js webpack production

当我在本地主机上运行 npm production 时,一切正常,但是在托管应用程序后,我尝试运行相同的命令( npm run prodnpm run production ),我总是收到相同的错误消息。

  • npm 版本:6.10.3
  • webpack 版本:webpack@3.12.0

  • //node_modules/laravel-mix/setup/webpack.config.js

    /**
     * As our first step, we'll pull in the user's webpack.mix.js
     * file. Based on what the user requests in that file,
     * a generic config object will be constructed for us.
     */
    
    require('../src/index');
    require(Mix.paths.mix());
    
    /**
     * Just in case the user needs to hook into this point
     * in the build process, we'll make an announcement.
     */
    
    Mix.dispatch('init', Mix);
    
    /**
     * Now that we know which build tasks are required by the
     * user, we can dynamically create a configuration object
     * for Webpack. And that's all there is to it. Simple!
     */
    
    let WebpackConfig = require('../src/builder/WebpackConfig');
    
    module.exports = new WebpackConfig().build();
    

    //package.json
    {
        "private": true,
        "scripts": {
            "dev": "npm run development",
            "development": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
            "watch": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --watch --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
            "watch-poll": "npm run watch -- --watch-poll",
            "hot": "cross-env NODE_ENV=development node_modules/webpack-dev-server/bin/webpack-dev-server.js --inline --hot --config=node_modules/laravel-mix/setup/webpack.config.js",
            "prod": "npm run production",
            "production": "cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --no-progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js"
        },
        "devDependencies": {
            "axios": "^0.19.0",
            "bootstrap": "^4.3.1",
            "cross-env": "^5.2.1",
            "jquery": "^3.4.1",
            "laravel-mix": "^1.0",
            "lodash": "^4.17.15",
            "popper.js": "^1.15.0",
            "vue": "^2.6.10",
            "vue-template-compiler": "^2.6.10"
        },
        "dependencies": {
            "aos": "^2.3.4",
            "laravel-echo": "^1.6.1",
            "laravel-vue-pagination": "^2.3.1",
            "node-sass": "^4.12.0",
            "pusher-js": "^4.4.0",
            "socket.io-client": "^2.3.0",
            "vee-validate": "^2.2.15",
            "vue-passport": "^1.0.13",
            "vue-resource": "^1.5.1",
            "vue-router": "^3.1.3",
            "vue-simple-spinner": "^1.2.8",
            "vue-sweetalert2": "^1.6.4",
            "vue-top-progress": "^0.7.0",
            "vuetify": "^1.5.18",
            "webpack": "^3.12.0"
        }
    }
    

    错误信息:
    npm ERR! code ELIFECYCLE
    npm ERR! errno 1
    npm ERR! @ production: `cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --no-progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js`
    npm ERR! Exit status 1
    npm ERR!
    npm ERR! Failed at the @ production 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!     /root/.npm/_logs/2019-10-10T13_38_27_403Z-debug.log
    

    最佳答案

    你不需要单独运行一个节点服务器来让你的 vueis 工作,你需要做的就是构建它并将它像任何其他 JavaScript 文件一样包含到你的 Laravel 应用程序中,如果你想参与服务器端渲染你可以使用 laravel 服务器端库或查看 phpv8 引擎

    关于vue.js - 托管应用程序后 npm run production 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58324354/

    相关文章:

    vue.js - 如何在Vuetify中对齐组件内部的内容?

    Sharepoint 测试后发布

    git - 如何在git中维护生产和开发分支?

    Angular 客户端和 webpack

    Golang 生产 Web 应用程序配置

    vue.js - Vue-FontAwesome : How to import all Free and Pro Icons? 重复声明错误

    javascript - 在 vuejs 模板中使用样式标签并从数据模型更新

    css - VueJS 中的全局样式与局部样式

    javascript - 如何修复 'TS2769: No overload matches this call'

    webpack 使用 uglifyjs 插件转换 css 单元