Path中的Webpack ERROR必须是一个字符串。收到undefined

时间:2016-11-05 09:52:14

标签: webpack webpack-dev-server

我将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"
  }

有人有建议吗?怎么解决这个问题?

5 个答案:

答案 0 :(得分:3)

我正在学习Writing your AngularJS with Redux

我得到了错误“ERROR in the”路径“参数必须是字符串类型。接收类型未定义 webpack:无法编译。enter image description here

最后,我根据CrzMarvin解决方案向webpack.config.js添加文件名( filename:'index.html',)来解决问题。 enter image description here

ThX CrzMarvin

答案 1 :(得分:1)

之前我遇到过同样的问题,然后我觉得这个插件出了问题。然后,我为这个插件添加了文件名。它工作了。

// webpack.config.js

plugins: [
    new HtmlWebpackPlugin({
        title: 'use plugin',
        filename: 'index.html'
    })
]

答案 2 :(得分:0)

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

答案 3 :(得分:0)

以下解决方案很好,并且适用于节点v14.2.0

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

答案 4 :(得分:-1)

问题的问题与节点6及更高版本有关。为节点5.x更改它可能会解决问题。