npm 运行 production 在托管应用程序后无法运行
npm run production not working after hosting the application
当我在本地主机上 运行 npm production 时,一切正常,但在托管应用程序后,我尝试 运行 相同的命令(npm run prod
或 npm 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 工作,你需要做的就是构建它并像其他任何东西一样将它包含到你的 laravel 应用程序中 JavaScript 文件,如果你想参与服务器端渲染,你可以使用 laravel 服务器端库或者查看 phpv8 引擎
laravel mix 版本有问题,请使用以下命令更新它
npm install laravel-mix@latest --save-dev
然后
npm install
当我在本地主机上 运行 npm production 时,一切正常,但在托管应用程序后,我尝试 运行 相同的命令(npm run prod
或 npm 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 工作,你需要做的就是构建它并像其他任何东西一样将它包含到你的 laravel 应用程序中 JavaScript 文件,如果你想参与服务器端渲染,你可以使用 laravel 服务器端库或者查看 phpv8 引擎
laravel mix 版本有问题,请使用以下命令更新它
npm install laravel-mix@latest --save-dev
然后
npm install