Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
495 views
in Technique[技术] by (71.8m points)

局部安装webpack,如何直接使用webpack命令?

在使用

  npm install webpack --save-dev

安装webpack后,webpack还不是内部命令,如何直接使用 webpack命令进行打包呢?

是设置环境变量吗?主要去设置哪个呢?
如果是设置环境变量的话,如果我有多个项目,运用不同版本的webpack,那我怎么设置呢?

还是说webpack本来一般就是全局安装呢?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

一般都不是全局安装,局部安装就可以。
在package.json中修改成如下:

{
  "scripts": {
    "start": "webpack"
  }
}

运行npm run start或npm start即可运行webpack


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...