在我的package.json文件中,我有这个脚本:
"scripts": {
"uglify:dist": "uglifyjs ./src/*.js -o ./build/js/app.min.js"
}
当我从命令行运行脚本时,它不会创建app.min.js
文件,而只会在屏幕上显示输出
$ npm run uglify:dist
> @ uglify:dist /home/user/Desktop/my-github-page
> uglifyjs ./src/*.js -o ./build/js/app.min.js
(function(){"use strict";angular.module("app",["fullPage.js","app.routes","app.footer.directive","app.nav.controller","app.nav.directive","app.main.controller","app.home.controller","app.home.directive","app.about.controller","app.about.directive","app.contact.controller","app.contact.directive","app.projects.controller","app.projects.directive"])})();
但是,当我直接从命令行运行uglifyjs时,它可以工作!
$ uglifyjs src/*.js -o build/js/app.min.js
我尝试过:
./build/js
存在npm install
版本
这里有什么问题?
答案 0 :(得分:0)
一切都正确,只需将uglify-js更新为最新版本。
答案 1 :(得分:0)
npm run *
命令在/node_modules
中使用本地模块,因此您应该在其中安装uglifyjs
,如下所示:npm install --save-dev uglifyjs
。