React JS - package.json中的webpack脚本不起作用
问题描述:
我正在做Tyler Mcginess的课程,我的package.json没有正确加载webpack -p,它返回了这个错误。React JS - package.json中的webpack脚本不起作用
在[email protected]生产脚本'webpack -p'失败。 npm ERR!这很可能是反应包的问题, npm ERR!不用npm本身
package.json。
{
"name": "react",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"production": "webpack -p"
},
"author": "",
"license": "ISC",
"dependencies": {
"react": "^15.0.1",
"react-dom": "^15.0.1"
},
"devDependencies": {
"babel-core": "^6.7.7",
"babel-loader": "^6.2.4",
"babel-preset-react": "^6.5.0",
"html-webpack-plugin": "^2.16.0",
"webpack": "^1.13.0",
"webpack-dev-server": "^1.14.1"
}
}
webpack.config.js。
module.exports = {
entry: [
'./app/index.js',
],
output: {
path: __dirname + '/dist',
filename: "index_bundle.js"
},
module: {
loaders: [
{test: /\.js$/, exclude: /node_modules/, loaders: "babel-loader"}
]
},
plugins: [HtmlWebpackPluginConfig]
}
答
在mac上,“。”文件是隐藏的,所以webpack没有拿起。扩展名,因此包括一个查询键传递给预置数组并删除.babelrc文件。
module: {
loaders: [
{
test: /\.js$/,
exclude: /node_modules/,
loader: "babel",
query: {
presets: ['es2015', 'react']
}
}
]
},
当您尝试在没有脚本的控制台中运行“webpack -p”时它会工作吗? – QoP
不,它不需要QOP –
LoadersList.js:81 \t \t r.forEach(函数(R){ \t \t^ 类型错误:r.forEach不是一个函数 –