What is the current behavior?
It fails to build and shows this:
cross-env NODE_ENV=production webpack --mode production --progress --hide-modules
[prerender-spa-plugin] You appear to be using the v2 argument-based configuration options. It's recommended that you migrate to the clearer object-based configuration system.
Check the documentation for more information.
Insufficient number of arguments or no entry found.
Alternatively, run 'webpack(-cli) --help' for usage info.
Hash: b472844c05bb4ae38896
Version: webpack 4.16.5
Time: 250ms
Built at: 10/08/2018 13:58:49
ERROR in Entry module not found: Error: Can't resolve './src' in '/home/maxie/Dropbox/Public/Learning/VueJS/vue-static'
Child html-webpack-plugin for "index.html":
1 asset
Entrypoint undefined = index.html
If the current behavior is a bug, please provide the steps to reproduce.
What is the expected behavior?
It should build the application successfully like how it was done here which worked until the warnings messages which got me to update the plugins and the config to what can be found in this repo.
Other relevant information:
webpack version: 4.16.5
Node.js version: 10.7.0
Operating System: ArchLinux x64 (Linux 4.17.11.a-1-hardened)
Additional tools: [email protected], [email protected]
This issue was moved from webpack/webpack#7874 by @montogeek. Original issue was by @Berkmann18.
Hi @berkmann18 . You'll need to do --entry=foo.bar
@ev1stensberg Okay, so the entry property was removed. Thanks for letting me know.
That might come of you using cross-env. First argument is your environment in cross env. Try without cross env just to test that it works. The entry property havent been removed.
I'm now getting this error:
NODE_ENV=production webpack --mode production --progress --hide-modules --entry=./src/main.js
/home/maxie/Dropbox/Public/Learning/VueJS/vue-static/node_modules/webpack-cli/bin/cli.js:244
throw err;
^
TypeError: loaderContext.emitError is not a function
at new module.exports (/home/maxie/Dropbox/Public/Learning/VueJS/vue-static/node_modules/vue-loader/lib/index.js:32:19)
at Object.<anonymous> (/home/maxie/Dropbox/Public/Learning/VueJS/vue-static/webpack.config.js:96:7)
at Module._compile (/home/maxie/Dropbox/Public/Learning/VueJS/vue-static/node_modules/v8-compile-cache/v8-compile-cache.js:178:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
at Module.load (internal/modules/cjs/loader.js:599:32)
at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
at Function.Module._load (internal/modules/cjs/loader.js:530:3)
at Module.require (internal/modules/cjs/loader.js:637:17)
at require (/home/maxie/Dropbox/Public/Learning/VueJS/vue-static/node_modules/v8-compile-cache/v8-compile-cache.js:159:20)
at WEBPACK_OPTIONS (/home/maxie/Dropbox/Public/Learning/VueJS/vue-static/node_modules/webpack-cli/bin/convert-argv.js:133:13)
at requireConfig (/home/maxie/Dropbox/Public/Learning/VueJS/vue-static/node_modules/webpack-cli/bin/convert-argv.js:135:6)
at /home/maxie/Dropbox/Public/Learning/VueJS/vue-static/node_modules/webpack-cli/bin/convert-argv.js:142:17
at Array.forEach (<anonymous>)
at module.exports (/home/maxie/Dropbox/Public/Learning/VueJS/vue-static/node_modules/webpack-cli/bin/convert-argv.js:140:15)
at yargs.parse (/home/maxie/Dropbox/Public/Learning/VueJS/vue-static/node_modules/webpack-cli/bin/cli.js:241:39)
at Object.parse (/home/maxie/Dropbox/Public/Learning/VueJS/vue-static/node_modules/webpack-cli/node_modules/yargs/yargs.js:563:18)
at /home/maxie/Dropbox/Public/Learning/VueJS/vue-static/node_modules/webpack-cli/bin/cli.js:219:8
at Object.<anonymous> (/home/maxie/Dropbox/Public/Learning/VueJS/vue-static/node_modules/webpack-cli/bin/cli.js:530:3)
at Module._compile (internal/modules/cjs/loader.js:689:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
at Module.load (internal/modules/cjs/loader.js:599:32)
at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
at Function.Module._load (internal/modules/cjs/loader.js:530:3)
at Module.require (internal/modules/cjs/loader.js:637:17)
at require (internal/modules/cjs/helpers.js:20:18)
at Object.<anonymous> (/home/maxie/Dropbox/Public/Learning/VueJS/vue-static/node_modules/webpack/bin/webpack.js:165:2)
at Module._compile (internal/modules/cjs/loader.js:689:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
at Module.load (internal/modules/cjs/loader.js:599:32)
at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
at Function.Module._load (internal/modules/cjs/loader.js:530:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:742:12)
at startup (internal/bootstrap/node.js:266:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:596:3)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
With the following webpack.config.js:
var path = require('path')
var webpack = require('webpack')
var PrerenderSpaPlugin = require('prerender-spa-plugin')
var HtmlWebpackPlugin = require('html-webpack-plugin')
var UglifyJsPlugin = require('uglifyjs-webpack-plugin')
var VueLoaderPlugin = require('vue-loader')
module.exports = {
entry: path.resolve(__dirname, 'src/main.js'),
output: {
path: path.resolve(__dirname, './dist'),
publicPath: '/',
filename: 'build.js'
},
module: {
rules: [{
test: /\.css$/,
use: [
'vue-style-loader',
'css-loader'
],
}, {
test: /\.vue$/,
loader: 'vue-loader',
options: {
loaders: {}
// other vue-loader options go here
}
},
{
test: /\.js$/,
loader: 'babel-loader',
exclude: /node_modules/
},
{
test: /\.(png|jpg|gif|svg)$/,
loader: 'file-loader',
options: {
name: '[name].[ext]?[hash]'
}
}
]
},
resolve: {
alias: {
'vue$': 'vue/dist/vue.esm.js'
},
extensions: ['*', '.js', '.vue', '.json']
},
devServer: {
historyApiFallback: true,
noInfo: true,
overlay: true
},
performance: {
hints: false
},
devtool: '#eval-source-map'
}
if (process.env.NODE_ENV === 'production') {
module.exports = {
mode: "production",
devtool: '#source-map',
optimization: {
minimizer: [
new UglifyJsPlugin({
sourceMap: true
})
]
},
plugins: [
new HtmlWebpackPlugin({
template: 'index.html',
filename: path.resolve(__dirname, 'dist/index.html')
}),
new PrerenderSpaPlugin({
// Absolute path to compiled SPA
staticDir: path.resolve(__dirname, './dist'),
// List of routes to prerender
routes: ['/', '/about', '/contact'],
// Options
postProcess(context) {
let titles = {
'/': 'My home page',
'/about': 'My awesome about page',
'/contact': 'Contact me'
};
context.html = context.html.replace(
/<title>[^<]*<\/title>/i,
`<title>${titles[context.route]}</title>`
)
return context
}
}),
new VueLoaderPlugin()
]
}
}
I tried looking at how the VueLoaderPlugin was supposed to be used after getting an error related to webpack not finding that loader and I think I did that bit right but webpack seems to not like that.
Could you post a repro in a seperate repository?
Would that be better than committing what I have now without the old configuration?
It would make it easier for us to debug
Okay, I'll do that then.
I deleted the other one and made a new repo.
Thanks! Will check it out during the week! Ping me friday if I haven't given you a response!
Okay, I'll do.
@ev1stensberg
Grabbing this next week, sorry for the hold up, but got a (very needed) vacation until monday
Can we keep this issue open until it's fully resolved so it's easier to track?
I think this is from PrerenderSpaPlugin or as from your stack trace:
at Object.<anonymous> (/home/maxie/Dropbox/Public/Learning/VueJS/vue-static/webpack.config.js:96:7) . Could you elaborate on what is on that line?
@ev1stensberg It's new VueLoaderPlugin().
I think the issue is that you either are using an outdated plugin or dependency. Most likely a plugin
@ev1stensberg It still happens with up-to-date dependencies tho.
> npm ls --depth=0
βββ @babel/[email protected]
βββ [email protected]
βββ [email protected]
βββ [email protected]
βββ [email protected]
βββ [email protected]
βββ [email protected]
βββ [email protected]
βββ [email protected]
βββ [email protected]
βββ [email protected]
βββ [email protected]
βββ [email protected]
βββ [email protected]
βββ [email protected]
βββ [email protected]
βββ [email protected]
Alright, could you try to run without cross env?
I get the same error without using cross env.
Okay. Could you open a repository for me to debug in?
At first glance it looks like your config doesnt get validated correctly, could you try with the βconfig flag?
@ev1stensberg Adding --config webpack.config.js doesn't change anything to the output above.
I updated the repo with the new changes.
try moving vue plugin to the top of plugin array. the error is from vue
Hey!
Try change:
var VueLoaderPlugin = require('vue-loader')
to
const VueLoaderPlugin = require('vue-loader/lib/plugin');
I had same problem - after that, works nice!
( https://vue-loader.vuejs.org/migrating.html#loader-inference )
@ev1stensberg I still get that error :s.
@piciuok After doing that, I get this error:
Error: [VueLoaderPlugin Error] No matching rule for .vue files found.
Make sure there is at least one root-level rule that matches .vue or .vue.html files.
at VueLoaderPlugin.apply (/home/maxie/GDrive/Learning/VueJS/vue-static/node_modules/vue-loader/lib/plugin.js:38:13)
at webpack (/home/maxie/GDrive/Learning/VueJS/vue-static/node_modules/webpack/lib/webpack.js:37:12)
at processOptions (/home/maxie/GDrive/Learning/VueJS/vue-static/node_modules/webpack-cli/bin/cli.js:441:16)
at yargs.parse (/home/maxie/GDrive/Learning/VueJS/vue-static/node_modules/webpack-cli/bin/cli.js:528:3)
at Object.parse (/home/maxie/GDrive/Learning/VueJS/vue-static/node_modules/yargs/yargs.js:563:18)
at /home/maxie/GDrive/Learning/VueJS/vue-static/node_modules/webpack-cli/bin/cli.js:219:8
at Object.<anonymous> (/home/maxie/GDrive/Learning/VueJS/vue-static/node_modules/webpack-cli/bin/cli.js:530:3)
at Module._compile (internal/modules/cjs/loader.js:689:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
at Module.load (internal/modules/cjs/loader.js:599:32)
at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
at Function.Module._load (internal/modules/cjs/loader.js:530:3)
at Module.require (internal/modules/cjs/loader.js:637:17)
at require (internal/modules/cjs/helpers.js:20:18)
at Object.<anonymous> (/home/maxie/GDrive/Learning/VueJS/vue-static/node_modules/webpack/bin/webpack.js:165:2)
at Module._compile (internal/modules/cjs/loader.js:689:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
at Module.load (internal/modules/cjs/loader.js:599:32)
at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
at Function.Module._load (internal/modules/cjs/loader.js:530:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:742:12)
at startup (internal/bootstrap/node.js:279:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:696:3)
No idea why I get this when the .vue files' location is specified in the config and the command.
if you are in prod mode, then you have no module.rules array to load .vue extensions.
How come? Was that deprecated?
no, it's how vue works if you read the docs and your own code π https://medium.freecodecamp.org/getting-started-with-vue-single-file-components-using-webpack-2ae078058688
guys I need help please....
webpack is watching the filesβ¦
Insufficient number of arguments or no entry found.
Alternatively, run 'webpack(-cli) --help' for usage info.
Hash: 385988a35ae66e7ab1b0
Version: webpack 4.29.6
Time: 112ms
Built at: 2019-04-03 01:11:53
ERROR in Entry module not found: Error: Can't resolve './main.js' in 'C:Users\nesca\Desktop\aula-es6'
Done in 3.49s.