извините за мой плохой английский sh.
В прошлый раз, npm run build работает нормально. Но после того, как я написал несколько строк и попытался запустить эту команду "npm run build", я получил ошибку Tip: built files are meant to be served over an HTTP server.
Opening index.html over file:// won't work.
Поэтому я попытался сбросить до последнего коммита, чтобы я мог успешно выполнить сборку, к сожалению, я снова сталкиваюсь с этой ошибкой.
Обычно, когда я пытаюсь запустить эту команду npm Запустить сборку, я получил несколько сгенерированных файлов в / dist, но теперь он говорит, что сборка завершена, но не генерирует файлы.
I попытался запустить этот npm run build --verbose
и получил журналы ошибок:
npm info it worked if it ends with ok
npm verb cli [ 'C:\\Program Files\\nodejs\\node.exe',
npm verb cli 'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
npm verb cli 'run',
npm verb cli 'build',
npm verb cli '--verbose' ]
npm info using npm@6.9.0
npm info using node@v10.16.3
npm verb run-script [ 'prebuild', 'build', 'postbuild' ]
npm info lifecycle mdbvue@5.8.0~prebuild: mdbvue@5.8.0
npm info lifecycle mdbvue@5.8.0~build: mdbvue@5.8.0
> mdbvue@5.8.0 build C:\xampp\htdocs\github\test1
> node build/build.js
npm info it worked if it ends with ok
npm verb cli [ 'C:\\Program Files\\nodejs\\node.exe',
npm verb cli 'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
npm verb cli 'prefix',
npm verb cli '-g' ]
npm info using npm@6.9.0
npm info using node@v10.16.3
npm verb exit [ 0, true ]
npm timing npm Completed in 118ms
npm info ok
Hash: e52fb455f4b88a7ca5d5
Version: webpack 4.39.3
Time: 20198ms
Built at: 03/16/2020 1:44:51 PM
Asset Size Chunks Chunk Names
index.html 635 bytes [emitted]
static/css/app.fe4d61491ae85d4536da.css 266 KiB app [emitted] [big] app
static/css/app.fe4d61491ae85d4536da.css.map 345 KiB app [emitted] app
static/css/vendors~app.3a3afdf0853d1018db0b.css 210 KiB vendors~app [emitted] vendors~app
static/css/vendors~app.3a3afdf0853d1018db0b.css.map 288 KiB vendors~app [emitted] vendors~app
static/favicon.ico 1.12 KiB [emitted]
static/fonts/Roboto-Bold.39b2c30.woff2 48.8 KiB [emitted]
static/fonts/Roboto-Bold.dc81817.woff 61.4 KiB [emitted]
static/fonts/Roboto-Bold.e31fcf1.ttf 125 KiB [emitted]
static/fonts/Roboto-Bold.ecdd509.eot 20.5 KiB [emitted]
static/fonts/Roboto-Light.3b813c2.woff 60.9 KiB [emitted]
static/fonts/Roboto-Light.46e48ce.ttf 124 KiB [emitted]
static/fonts/Roboto-Light.69f8a06.woff2 48.2 KiB [emitted]
static/fonts/Roboto-Light.a990f61.eot 20.4 KiB [emitted]
static/fonts/Roboto-Medium.4d9f3f9.eot 20.9 KiB [emitted]
static/fonts/Roboto-Medium.574fd0b.woff2 49 KiB [emitted]
static/fonts/Roboto-Medium.894a2ed.ttf 125 KiB [emitted]
static/fonts/Roboto-Medium.fc78759.woff 61.5 KiB [emitted]
static/fonts/Roboto-Regular.2751ee4.woff2 48.1 KiB [emitted]
static/fonts/Roboto-Regular.30799ef.eot 20.8 KiB [emitted]
static/fonts/Roboto-Regular.ba3dcd8.woff 60.3 KiB [emitted]
static/fonts/Roboto-Regular.df7b648.ttf 123 KiB [emitted]
static/fonts/Roboto-Thin.7500519.woff 60.2 KiB [emitted]
static/fonts/Roboto-Thin.9499847.ttf 125 KiB [emitted]
static/fonts/Roboto-Thin.954bbde.woff2 47.4 KiB [emitted]
static/fonts/Roboto-Thin.dfe56a8.eot 21.2 KiB [emitted]
static/fonts/fa-brands-400.14c590d.eot 127 KiB [emitted]
static/fonts/fa-brands-400.3e1b2a6.woff2 72.8 KiB [emitted]
static/fonts/fa-brands-400.5e8aa9e.ttf 126 KiB [emitted]
static/fonts/fa-brands-400.df02c78.woff 85.5 KiB [emitted]
static/fonts/fa-regular-400.285a9d2.ttf 33.3 KiB [emitted]
static/fonts/fa-regular-400.5623624.woff 16.4 KiB [emitted]
static/fonts/fa-regular-400.aa66d0e.eot 33.6 KiB [emitted]
static/fonts/fa-regular-400.ac21cac.woff2 13.3 KiB [emitted]
static/fonts/fa-solid-900.3ded831.woff 95.7 KiB [emitted]
static/fonts/fa-solid-900.42e1fbd.eot 188 KiB [emitted]
static/fonts/fa-solid-900.896e20e.ttf 187 KiB [emitted]
static/fonts/fa-solid-900.d6d8d5d.woff2 73.6 KiB [emitted]
static/img/background.a052cf6.svg 62.9 KiB [emitted]
static/img/background.b568f39.jpg 130 KiB [emitted]
static/img/client-luljettas.622654c.svg 67.7 KiB [emitted]
static/img/client-marikina.db2eb35.svg 61.3 KiB [emitted]
static/img/fa-brands-400.bfa9c38.svg 675 KiB [emitted] [big]
static/img/fa-regular-400.95f13e0.svg 141 KiB [emitted]
static/img/fa-solid-900.6ed5e3b.svg 820 KiB [emitted] [big]
static/img/freelancer.b73e0f3.svg 60.6 KiB [emitted]
static/img/github-contributor.1ca5d17.svg 19.4 KiB [emitted]
static/img/ongoing-project.d524cda.svg 33.7 KiB [emitted]
static/img/software-engineer.a67e353.svg 20.4 KiB [emitted]
static/js/0.74eb05759f83e93c3bee.js 96.4 KiB 0 [emitted]
static/js/0.74eb05759f83e93c3bee.js.map 109 KiB 0 [emitted]
static/js/1.9276c013ba33d0268746.js 12.2 KiB 1 [emitted]
static/js/1.9276c013ba33d0268746.js.map 6.07 KiB 1 [emitted]
static/js/10.30636d71bc9ec5a0cc21.js 15.7 KiB 10 [emitted]
static/js/10.30636d71bc9ec5a0cc21.js.map 12.7 KiB 10 [emitted]
static/js/11.2fbcf17ae46cc72ee115.js 19.4 KiB 11 [emitted]
static/js/11.2fbcf17ae46cc72ee115.js.map 19.3 KiB 11 [emitted]
static/js/12.3239bb79db524273734d.js 16.1 KiB 12 [emitted]
static/js/12.3239bb79db524273734d.js.map 13.5 KiB 12 [emitted]
static/js/13.013706bf533f897712b6.js 11.6 KiB 13 [emitted]
static/js/13.013706bf533f897712b6.js.map 5.48 KiB 13 [emitted]
static/js/2.4e2db91152b7e097ceae.js 11.6 KiB 2 [emitted]
static/js/2.4e2db91152b7e097ceae.js.map 5.49 KiB 2 [emitted]
static/js/3.2f94cb6c4b1498655217.js 15.7 KiB 3 [emitted]
static/js/3.2f94cb6c4b1498655217.js.map 12.8 KiB 3 [emitted]
static/js/4.f81d6231701f95290493.js 17.2 KiB 4 [emitted]
static/js/4.f81d6231701f95290493.js.map 16.1 KiB 4 [emitted]
static/js/5.0423f1e8418588c74353.js 11.6 KiB 5 [emitted]
static/js/5.0423f1e8418588c74353.js.map 5.48 KiB 5 [emitted]
static/js/6.51dd3c223742f1f328bd.js 17.3 KiB 6 [emitted]
static/js/6.51dd3c223742f1f328bd.js.map 16.6 KiB 6 [emitted]
static/js/7.85b273216ca678d34cfd.js 19.4 KiB 7 [emitted]
static/js/7.85b273216ca678d34cfd.js.map 20.8 KiB 7 [emitted]
static/js/8.dd74116e839b7742a611.js 11.7 KiB 8 [emitted]
static/js/8.dd74116e839b7742a611.js.map 5.51 KiB 8 [emitted]
static/js/9.cf39afeccdd88108ac33.js 16.3 KiB 9 [emitted]
static/js/9.cf39afeccdd88108ac33.js.map 13.9 KiB 9 [emitted]
static/js/app.d79fa5cd7c434215023f.js 1020 KiB app [emitted] [big] app
static/js/app.d79fa5cd7c434215023f.js.map 591 KiB app [emitted] app
static/js/vendors~app.e8ed788f97ce79ec1dbb.js 1.6 MiB vendors~app [emitted] [big] vendors~app
static/js/vendors~app.e8ed788f97ce79ec1dbb.js.map 1.96 MiB vendors~app [emitted] vendors~app
Entrypoint app [big] = static/js/vendors~app.e8ed788f97ce79ec1dbb.js static/css/vendors~app.3a3afdf0853d1018db0b.css static/js/vendors~app.e8ed788f97ce79ec1dbb.js.map static/css/vendors~app.3a3afdf0853d1018db0b.css.map static/js/app.d79fa5cd7c434215023f.js static/css/app.fe4d61491ae85d4536da.css static/js/app.d79fa5cd7c434215023f.js.map static/css/app.fe4d61491ae85d4536da.css.map
Build complete.
Tip: built files are meant to be served over an HTTP server.
Opening index.html over file:// won't work.
npm verb lifecycle mdbvue@5.8.0~build: unsafe-perm in lifecycle true
npm verb lifecycle mdbvue@5.8.0~build: PATH: C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin;C:\xampp\htdocs\github\test1\node_modules\.bin;C:\Users\User1\bin;C:\Program Files\Git\mingw64\bin;C:\Program Files\Git\usr\local\bin;C:\Program Files\Git\usr\bin;C:\Program Files\Git\usr\bin;C:\Program Files\Git\mingw64\bin;C:\Program Files\Git\usr\bin;C:\Users\User1\bin;C:\ProgramData\DockerDesktop\version-bin;C:\Program Files\Docker\Docker\Resources\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0;C:\Windows\System32\OpenSSH;C:\Program Files\MySQL\MySQL Server 5.5\bin;C:\Program Files (x86)\GtkSharp\2.12\bin;C:\Program Files (x86)\Yarn\bin;C:\ProgramData\ComposerSetup\bin;C:\Program Files\Git\cmd;C:\Program Files (x86)\Microsoft SQL Server\Client SDK\ODBC\130\Tools\Binn;C:\Program Files (x86)\Microsoft SQL Server\140\Tools\Binn;C:\Program Files (x86)\Microsoft SQL Server\140\DTS\Binn;C:\Program Files (x86)\Microsoft SQL Server\140\Tools\Binn\ManagementStudio;C:\php\php71;C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\130\Tools\Binn;C:\Program Files\Microsoft SQL Server\140\Tools\Binn;C:\Program Files\Microsoft SQL Server\140\DTS\Binn;C:\Program Files\nodejs;C:\Program Files\Java\jdk-12.0.1\bin;C:\Users\User1\AppData\Local\Programs\Microsoft VS Code\bin;C:\Users\User1\AppData\Roaming\npm;C:\Program Files\Git\usr\bin\vendor_perl;C:\Program Files\Git\usr\bin\core_perl
npm verb lifecycle mdbvue@5.8.0~build: CWD: C:\xampp\htdocs\github\test1
npm info lifecycle mdbvue@5.8.0~postbuild: mdbvue@5.8.0
npm verb exit [ 0, true ]
npm timing npm Completed in 25731ms
npm info ok
Я пытаюсь найти возможное решение для этого. Я попытался изменить с '/' на './' assetsPublicPath в config / index. js. Но, к сожалению, это не работает.
Вот мой конфиг / индекс. js file
'use strict'
// Template version: 1.1.3
// see http://vuejs-templates.github.io/webpack for documentation.
const path = require('path')
module.exports = {
build: {
env: require('./prod.env'),
index: path.resolve(__dirname, '../dist/index.html'),
assetsRoot: path.resolve(__dirname, '../dist'),
assetsSubDirectory: 'static',
assetsPublicPath: './',
productionSourceMap: true,
// Gzip off by default as many popular static hosts such as
// Surge or Netlify already gzip all static assets for you.
// Before setting to `true`, make sure to:
// npm install --save-dev compression-webpack-plugin
productionGzip: false,
productionGzipExtensions: ['js', 'css'],
// Run the build command with an extra argument to
// View the bundle analyzer report after build finishes:
// `npm run build --report`
// Set to `true` or `false` to always turn it on or off
bundleAnalyzerReport: process.env.npm_config_report
},
dev: {
env: require('./dev.env'),
port: process.env.PORT || 8080,
autoOpenBrowser: true,
assetsSubDirectory: 'static',
assetsPublicPath: '/',
proxyTable: {},
// CSS Sourcemaps off by default because relative paths are "buggy"
// with this option, according to the CSS-Loader README
// (https://github.com/webpack/css-loader#sourcemaps)
// In our experience, they generally work as expected,
// just be aware of this issue when enabling this option.
cssSourceMap: false
}
}
Вот мой webpack.prod.conf. js
'use strict'
const path = require('path')
const utils = require('./utils')
const webpack = require('webpack')
const config = require('../config')
const merge = require('webpack-merge')
const baseWebpackConfig = require('./webpack.base.conf')
const CopyWebpackPlugin = require('copy-webpack-plugin')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const ExtractTextPlugin = require('extract-text-webpack-plugin')
const UglifyJsPlugin = require('uglifyjs-webpack-plugin')
const env = config.build.env
const webpackConfig = merge(baseWebpackConfig, {
module: {
rules: utils.styleLoaders({
sourceMap: config.build.productionSourceMap,
extract: true
})
},
devtool: config.build.productionSourceMap ? '#source-map' : false,
output: {
path: config.build.assetsRoot,
filename: utils.assetsPath('js/[name].[chunkhash].js'),
chunkFilename: utils.assetsPath('js/[id].[chunkhash].js')
},
optimization: {
minimizer: [
new UglifyJsPlugin()
],
splitChunks: {
chunks: 'all'
}
},
plugins: [
// http://vuejs.github.io/vue-loader/en/workflow/production.html
new webpack.DefinePlugin({
'process.env': env
}),
// extract css into its own file
new ExtractTextPlugin({
filename: utils.assetsPath('css/[name].[md5:contenthash:hex:20].css')
}),
// Compress extracted CSS. We are using this plugin so that possible
// duplicated CSS from different components can be deduped.
// generate dist index.html with correct asset hash for caching.
// you can customize output by editing /index.html
// see https://github.com/ampedandwired/html-webpack-plugin
new HtmlWebpackPlugin({
filename: config.build.index,
template: 'index.html',
inject: true,
minify: {
removeComments: true,
collapseWhitespace: true,
removeAttributeQuotes: true
// more options:
// https://github.com/kangax/html-minifier#options-quick-reference
},
// necessary to consistently work with multiple chunks via CommonsChunkPlugin
chunksSortMode: 'dependency'
}),
// copy custom static assets
new CopyWebpackPlugin([
{
from: path.resolve(__dirname, '../static'),
to: config.build.assetsSubDirectory,
ignore: ['.*']
}
])
]
})
if (config.build.productionGzip) {
const CompressionWebpackPlugin = require('compression-webpack-plugin')
webpackConfig.plugins.push(
new CompressionWebpackPlugin({
asset: '[path].gz[query]',
algorithm: 'gzip',
test: new RegExp(
'\\.(' +
config.build.productionGzipExtensions.join('|') +
')$'
),
threshold: 10240,
minRatio: 0.8
})
)
}
if (config.build.bundleAnalyzerReport) {
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin
webpackConfig.plugins.push(new BundleAnalyzerPlugin())
}
module.exports = webpackConfig