嘿,我正在尝试webpack。我一直在关注一些教程,但遇到了一些问题。我已经在要使用的文件夹中本地安装了webpack
npm install webpack --save-dev
我制作了两个JS脚本,我想将它们捆绑在一起,并尝试按照命令进行操作
webpack script-1.js /.bundle.js
然后我按照教师的建议尝试在全球范围内安装webpack,但是我仍然不断遇到bash: webpack: command not found
错误。
然后我在这里看到线程建议使用Webpack的完整路径,或者将带有其值的build关键字添加到我的package.json
中,然后在终端中运行npm run build
。以下是我为package.json
"scripts": {
"build": "webpack"
}
当我不断遇到相同的错误时,他们都没有为我工作。
这是我的json文件。
{
"name": "webpack-playlist",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"build": "webpack"
},
"repository": {
"type": "git",
"url": "git+https://github.com/iamshaunjp/webpack-playlist.git"
},
"author": "",
"license": "ISC",
"bugs": {
"url": "https://github.com/iamshaunjp/webpack-playlist/issues"
},
"homepage": "https://github.com/iamshaunjp/webpack-playlist#readme",
"devDependencies": {
"webpack": "^4.16.0",
"webpack-command": "^0.4.1"
},
"dependencies": {
"npm": "^6.1.0"
}
}
任何形式的协助都将受到赞赏。谢谢。