Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Webpack 4 Entrypoint undefined #895

Closed
ErikSchierboom opened this issue Mar 9, 2018 · 42 comments
Closed

Webpack 4 Entrypoint undefined #895

ErikSchierboom opened this issue Mar 9, 2018 · 42 comments

Comments

@ErikSchierboom
Copy link

ErikSchierboom commented Mar 9, 2018

Description

When working with Webpack 4, people can now start with zero-configuration. This allows one to quickly get started with using Webpack, without any of the configuration hassle. Trying out Webpack 4, I tried to create a minimal configuration that uses the HtmlWebpackPlugin (see the Config section). While functionally working, I do get a warning about an undefined entrypoint.

While I can ignore this warning, I'm not sure if there actually is a problem or if there is something I can do about it. If there is something wrong in my configuration, it would be great if a message was printed that explains how to fix it.

I can reproduce this is in both development and production mode.

Error Message & Stack Trace

Entrypoint undefined = index.html

Config

Minimal version:

const HtmlWebpackPlugin = require('html-webpack-plugin');

module.exports = {
    plugins: [new HtmlWebpackPlugin()]
};

More explicit version that also has the warning:

const HtmlWebpackPlugin = require('html-webpack-plugin');

module.exports = {
  entry: './src/index.js',
  output: {
    path: __dirname + '/dist',
    filename: 'bundle.js'
  },

  plugins: [new HtmlWebpackPlugin()]
};

Version with HTML loader that also has the warning:

const HtmlWebpackPlugin = require('html-webpack-plugin');

module.exports = {
  entry: './src/index.js',
  output: {
    path: __dirname + '/dist',
    filename: 'bundle.js'
  },
  module: {
    rules: [
      { test: /\.html$/i, loader: 'html-loader' },
    ]
  },

  plugins: [new HtmlWebpackPlugin()]
};

Environment

node -e "var os=require('os');console.log('Node.js ' + process.version + '\n' + os.platform() + ' ' + os.release())"
Node.js v8.9.3
win32 10.0.14393

npm --version
5.6.0

npm ls webpack
[email protected]

npm ls html-webpack-plugin
[email protected]
@sukonzer
Copy link

sukonzer commented Mar 9, 2018

233

html-webpack-plugin 3.0.6

I have an same issue with you

@jantimon
Copy link
Owner

jantimon commented Mar 9, 2018

The entry point is injected into webpack - what would be the correct way to give it a name?

@ErikSchierboom
Copy link
Author

Is this a Webpack issue then?

@jantimon
Copy link
Owner

jantimon commented Mar 9, 2018

Does it produce any error or is this just a cosmetic issue?

@ErikSchierboom
Copy link
Author

It is just a cosmetic issue, so it is not really that important. It just might be confusing for new users.

@jantimon
Copy link
Owner

jantimon commented Mar 9, 2018

If someone can find out how we can change it I would love to merge it into the plugin

@ErikSchierboom
Copy link
Author

@sokra Do you perhaps know how the HtmlWebpackPlugin can ensure that Webpack does not specify the entrypoint as undefined? (see the discussion in this issue)

@yash2code
Copy link

its giving same error even when providing template and filename options .

@ghost
Copy link

ghost commented Mar 11, 2018

Same issue.

plugins: [
        new HtmlWebpackPlugin({
            template: './src/index.html',
            …
Child html-webpack-plugin for "index.html":
     1 asset
    Entrypoint undefined = index.html
       [0] ./node_modules/html-webpack-plugin/lib/loader.js!./src/index.html 15.2 KiB {0} [built]

@fralonra
Copy link

Same issue

webpack.config.js

...
plugins: [
      ...
      new HtmlWebPackPlugin({
        title: '...',
        template: path.resolve(folderSrc, 'index.html'),
        filename: 'index.html',
        hash: true
      })
    ]
...

Output

...
Child html-webpack-plugin for "index.html":
     1 asset
    Entrypoint undefined = index.html
...

Env

node v9.7.1
npm 5.7.1
webpack 4.1.1
html-webpack-plugin 3.0.6

@zD98
Copy link

zD98 commented Mar 13, 2018

    stats: {
        ...
        children: false, 
        ...
    },

Setting the property children to false will show off the log info.
But I don't know how to change it or solve it.

@ecanro
Copy link

ecanro commented Mar 16, 2018

Child html-webpack-plugin for "index.html":
1 asset
Entrypoint undefined = index.html

the same error is not cosmetic, since the script stops and the bundle does not end

@sokra
Copy link
Contributor

sokra commented Mar 16, 2018

Do you perhaps know how the HtmlWebpackPlugin can ensure that Webpack does not specify the entrypoint as undefined? (see the discussion in this issue)

yep, provide all arguments to the SingleEntryPlugin constructor:

new SingleEntryPlugin(this.context, template).apply(childCompiler);

The last one is the entrypoint name.

@khuyennguyen7007
Copy link

I'm just install and config html-loader. Then it working properly. So you can try

@jantimon
Copy link
Owner

Fixed in 3.0.7

@ecanro
Copy link

ecanro commented Mar 19, 2018

I updated the package to the latest version, but I do not know why it continues with "some" error and the script does not end, please help

Child html-webpack-plugin for "index.html":
1 asset
Entrypoint html-webpack-plugin for "index.html" = index.html
[0] (webpack)/buildin/module.js 519 bytes {0} [built]
[1] (webpack)/buildin/global.js 509 bytes {0} [built]
[3] ./node_modules/html-webpack-plugin/lib/loader.js!./src/assets/index.html 708 bytes {0} [built]
+ 1 hidden module
npm ERR! code ELIFECYCLE
npm ERR! errno 2

this is my log file:
0 info it worked if it ends with ok
1 verbose cli [ 'C:\Program Files\nodejs\node.exe',
1 verbose cli 'C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js',
1 verbose cli 'run-script',
1 verbose cli 'build' ]
2 info using [email protected]
3 info using [email protected]
4 verbose run-script [ 'prebuild', 'build', 'postbuild' ]
5 info lifecycle [email protected]prebuild: [email protected]
6 info lifecycle [email protected]
build: [email protected]
7 verbose lifecycle [email protected]build: unsafe-perm in lifecycle true
8 verbose lifecycle [email protected]
build: PATH: C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin;E:\Apps\React\reacttr\node_modules.bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0;C:\Program Files\nodejs;C:\ProgramData\ComposerSetup\bin;C:\Program Files\Git\cmd;C:\Program Files\Intel\WiFi\bin;C:\Program Files\Common Files\Intel\WirelessCommon;C:\RailsInstaller\Git\cmd;C:\RailsInstaller\Ruby2.2.0\bin;C:\Users\Edgar Calderon\AppData\Local\Microsoft\WindowsApps;C:\Users\Edgar Calderon\AppData\Roaming\npm;C:\AppServ\Apache24\bin;C:\AppServ\php5;C:\AppServ\MySQL\bin;C:\Users\Edgar Calderon\AppData\Roaming\Composer\vendor\bin;C:\Program Files\Microsoft VS Code\bin;C:\Program Files\Intel\WiFi\bin;C:\Program Files\Common Files\Intel\WirelessCommon;C:\Users\Edgar Calderon\AppData\Local\atom\bin
9 verbose lifecycle [email protected]build: CWD: E:\Apps\React\reacttr
10 silly lifecycle [email protected]
build: Args: [ '/d /s /c', 'webpack --mode development --colors' ]
11 silly lifecycle [email protected]build: Returned: code: 2 signal: null
12 info lifecycle [email protected]
build: Failed to exec build script
13 verbose stack Error: [email protected] build: webpack --mode development --colors
13 verbose stack Exit status 2
13 verbose stack at EventEmitter. (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\index.js:285:16)
13 verbose stack at emitTwo (events.js:126:13)
13 verbose stack at EventEmitter.emit (events.js:214:7)
13 verbose stack at ChildProcess. (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\lib\spawn.js:55:14)
13 verbose stack at emitTwo (events.js:126:13)
13 verbose stack at ChildProcess.emit (events.js:214:7)
13 verbose stack at maybeClose (internal/child_process.js:925:16)
13 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)
14 verbose pkgid [email protected]
15 verbose cwd E:\Apps\React\reacttr
16 verbose Windows_NT 10.0.16299
17 verbose argv "C:\Program Files\nodejs\node.exe" "C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js" "run-script" "build"
18 verbose node v8.9.4
19 verbose npm v5.6.0
20 error code ELIFECYCLE
21 error errno 2
22 error [email protected] build: webpack --mode development --colors
22 error Exit status 2
23 error Failed at the [email protected] build script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 2, true ]

@jantimon
Copy link
Owner

Please report bugs here #900

@ErikSchierboom
Copy link
Author

Thanks for the fix @jantimon!

@jantimon
Copy link
Owner

@ErikSchierboom please note that we will probably revert this change because of #900

@ghost
Copy link

ghost commented Mar 20, 2018

The last version did not fix hmr for me. Html files doesn't update after compile.

@avaleriani
Copy link

HMR not working for me in 3.1.0 and still entrypoint appears as undefined.

@jantimon
Copy link
Owner

Can you please try older versions and let me know which version works with HMR for you?

@glowkeeper
Copy link

Same issue

@zenoven
Copy link

zenoven commented Apr 1, 2018

same issue in v3.1.0 with webpack config below

...
const config = {
  mode: mode,
  entry: {
    index: './index.js'
  },
  context: projectPath,
  output: {
    filename: '[name].[chunkhash:22].js',
    chunkFilename: '[name].[chunkhash:22].js',
    path: buildPath
  },

  plugins: [
    new HTMLWebpackPlugin({
      template: 'index.html',
    })
  ]
}

@superjose
Copy link

There seems to be a regression from 3.0.7 to 3.1.0. Installing 3.0.7 fixes the issue:

"devDependencies": {
    "html-webpack-plugin": "3.0.7",
}

@jpike88
Copy link

jpike88 commented Apr 5, 2018

Was also getting this error in addition to the entrypoint undefined one

screen shot 2018-04-05 at 10 54 07 am

Downgrading to 3.0.7 fixed the issue for me too.

@jantimon
Copy link
Owner

jantimon commented Apr 5, 2018

We introduced a fix in 3.0.7 but removed it again in 3.0.8 because of many errors which were reported in #900

@jpike88 this is unrelated to the current issue could you please create a new issue?

@jpike88
Copy link

jpike88 commented Apr 5, 2018

sorry, moved onto fuse-box...

@superjose
Copy link

@jantimon Bam! Guess that explains it. Thanks for the update. There should be something in the documentation that states the current problem, and the workaround. People will be spending several hours trying to fix a problem that it's not their own.

@jantimon
Copy link
Owner

jantimon commented Apr 5, 2018

@superjose - actually it’s not an error just a meaningless log message :)
So the workaround would be to ignore it (although I really don’t like that approach)
I would be very happy for any help or idea how we or the webpack-dev-server team could fix #900 so we can apply the solution of 3.0.7 again

@ecanro
Copy link

ecanro commented Apr 11, 2018

In the past it was a job for extract-text-webpack-plugin.

Unfortunately said plugin does not play well with webpack 4.

According to Michael Ciniawsky:

extract-text-webpack-plugin reached a point where maintaining it become too much of a burden and it’s not the first time upgrading a major webpack version was complicated and cumbersome due to issues with it

now i userd "mini-css-extract-plugin" is here to overcome those issues

@leedorian
Copy link

Same issue here, v3.2.0

@rogerramosme
Copy link

same issue here :(
v3.2.0

@kl2karpenko
Copy link

Same here!) Please do something!)

@danitrimujianto
Copy link

same issue.. need help....

@yuanzx
Copy link

yuanzx commented Apr 18, 2018

Same issue here, v3.2.0

@jantimon
Copy link
Owner

Please see #895 (comment)

@erosenberg
Copy link

Same issue here, v3.2.0

@ShaneCallanan
Copy link

ShaneCallanan commented Apr 23, 2018

Hope someone can fix #900 soon so this issue can be swiftly resolved.
I can't get through the build phase atm

@superjose
Copy link

@jantimon Thanks for the response! I think everyone will come flocking around without actually reading the issue. Why not put it on the front of the README.md that it's a false positive?

@AhHa45
Copy link

AhHa45 commented May 30, 2018

it's not a meaningless log issue as the build fails...

@jantimon
Copy link
Owner

jantimon commented May 30, 2018

@AhHa45 It does not cause the build to fail - it might be the last log message of webpack before your build fails.

If it really causes a build failure please open a bug report with a reproduction example.

Please see #895 (comment)

Repository owner locked as resolved and limited conversation to collaborators May 30, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests