javascript - Entry module not found: Can't resolve './assets/app.js' -


i'm trying use webpack error

$ node_modules/.bin/webpack hash: d1aee5dc037997fae5a6 version: webpack 3.4.1 time: 31ms  error in entry module not found: error: can't resolve './assets/app.js' in 'd:\template\src' 

it's first time using webpack.

here script

const path = require('path'); const webpack = require('webpack'); module.exports = {   context: path.resolve(__dirname, './src'),   entry: {     app: './assets/app.js',   },   output: {     path: path.resolve(__dirname, './node_modules'),     filename: '[name].bundle.js',   }, }; 

my folder structure

enter image description here

i think error here context: path.resolve(__dirname, './src'), don't know replace part.

i read https://webpack.github.io/docs/tutorials/getting-started , try searching google how use webpack. solutions ?.

  "devdependencies": {     "buefy": "",     "bulma": "",     "vue": "^2.1.10",     "webpack": "^3.4.1"   }, 

the context option defines base directory used resolve in webpack config. using ./src/ base directory, ./assets/app.js resolved inside src directory (it technically ./src/assets/app.js).

if no context provided, webpack use current directory, want. can remove context entirely config. want output bundle directory such ./dist instead of ./node_modules. config follows.

const path = require('path'); const webpack = require('webpack');  module.exports = {   entry: {     app: './assets/app.js',   },   output: {     path: path.resolve(__dirname, './dist'),     filename: '[name].bundle.js',   }, }; 

you looking @ webpack 1 docs, should use newer docs, better: webpack - getting started.


Comments

Popular posts from this blog

javascript - Create a stacked percentage column -

Optimising Firebase database by automatically overwriting data -

javascript - Angular UI-Grid customTemplate directive causing rows to load slowly/? -