当我尝试在项目中运行“webpack”时,命令行显示以下错误:
“webpack”未被识别为内部或外部命令、可操作程序或批处理文件。
我已经使用以下命令安装了webpack,
npm install webpack babel-core babel loader babel-preset-es2015 babel-preset-react react react-dom --save
即使我尝试了这个被接受的answer,它也伴随着另一个错误。x1c 0d1x
webpack.config.js文件
module.exports = {
entry: './src/index.js',
output: {
path: './dist',
filename: 'bundle.js'
},
module: {
loaders: [{
test: /\.jsx?$/,
exclude: /node_modules/,
loader: 'babel-loader',
query: {
presets: ['es2015', 'react']
}
}]
}}
package.json文件
{
"name": "dummytextgen",
"version": "1.0.0",
"description": "Simple dummy text generator",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"compile": "webpack --config webpack.config.js"
},
"author": "",
"license": "ISC",
"dependencies": {
"babel-core": "^6.26.0",
"babel-loader": "^7.1.4",
"babel-preset-es2015": "^6.24.1",
"babel-preset-react": "^6.24.1",
"react": "^16.3.1",
"react-dom": "^16.3.1",
"webpack": "^4.5.0"
},
"devDependencies": {
"webpack-cli": "^2.0.14"
}
}
使用操作系统- Windows 8,npm版本- 5.6.0
3条答案
按热度按时间byqmnocz1#
当您尝试从项目文件夹中执行weback时,您可能会尝试给予webpack二进制文件的确切路径:
vybvopom2#
根据截图,你需要更新规则,我已经更新了配置文件,它的工作正常。请通过。
网页包配置. js
包. json
0yg35tkg3#
应该有帮助