我有以下简单的 webpack.config.js 文件:
var webpack = require("webpack"); //LINE OF INTEREST
module.exports = {
entry: ["./main.js"],
output: {
path: "./build",
filename: "bundle.js"
},
module: {
loaders: [
{ test: /\.css$/, loader: 'style-loader!css-loader' }
]
},
plugins: [
new webpack.ProvidePlugin({
$: "jquery",
jQuery: "jquery"
})
]
};
当我注释掉定义 webpack 的第一行时,我收到一个错误,因为我在定义 ProvidePlugin 时引用了 webpack。但是,当我包含第一行时,我收到以下神秘错误:
ERROR in (webpack)/package.json
Module parse failed: /var/www/html/node_modules/webpack/package.json Unexpected token (2:9)
You may need an appropriate loader to handle this file type.
SyntaxError: Unexpected token (2:9)
首先,我不确定为什么我的 node_modules 文件夹是我的 apache 根目录。其次,为什么我会收到解析错误?文件不是package.json
通过 npm 安装的吗?怎么可能有语法错误?