Webpack错误:路径必须是字符串。收到未定义。

11

我将我的node.js更新到7版本。在运行项目中的webpack后,我收到了错误信息:ERROR in Path must be a string. Received undefined

我的package.json文件:

"dependencies": {
    "react": "^15.3.1",
    "react-native": "^0.33.0",
    "react-redux": "^4.4.5",
    "react-web": "0.4.5",
    "redux": "^3.6.0",
    "redux-thunk": "^2.1.0",
    "remote-redux-devtools": "^0.4.8"
  },
  "devDependencies": {
    "babel-core": "^6.18.2",
    "babel-loader": "^6.2.7",
    "babel-preset-react-native": "^1.9.0",
    "babel-preset-stage-1": "^6.16.0",
    "haste-resolver-webpack-plugin": "^0.2.2",
    "json-loader": "^0.5.4",
    "react-dom": "^15.3.2",
    "react-hot-loader": "^1.3.0",
    "webpack": "^1.13.3",
    "webpack-dev-server": "^1.16.2",
    "webpack-html-plugin": "^0.1.1"
  }

有人有建议吗?如何解决这个问题?


同样的问题在这里。 - Johny19
这里也有同样的问题... 有更新吗? - Kiril Aleksandrov
4个回答

7

当我学习使用Redux编写AngularJS时,出现了错误:“ERROR in The "path" argument must be of type string. Received type undefined webpack: Failed to compile.enter image description here

最后,我按照CrzMarvin的解决方案,在webpack.config.js中添加文件名(filename: 'index.html',),并解决了问题。enter image description here

感谢CrzMarvin


1
我之前遇到过同样的问题,然后我认为插件出了问题。于是,我在这个插件中添加了文件名。结果它就可以工作了。
// webpack.config.js
plugins: [
    new HtmlWebpackPlugin({
        title: 'use plugin',
        filename: 'index.html'
    })
]

0

你应该安装 html-webpack-plugin 依赖而不是 webpack-html-plugin。我之前也遇到了同样的问题。


0

以下解决方案可行且适用于node v14.2.0

new HtmlWebpackPlugin({
  title: 'use plugin',
  filename: 'index.html',
  template: path.join(client.srcPath, client.entryHtml)
})

请正确格式化您的代码,点击此处了解如何操作 - rizerphe
2
虽然这段代码可能解决了问题,但是包括解释它如何以及为什么解决了问题将有助于提高您的帖子质量,并可能导致更多的赞。请记住,您正在回答未来读者的问题,而不仅仅是现在提问的人。请[编辑]您的答案以添加解释并指出适用的限制和假设。 - rizerphe

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接