简体   繁体   English

如何全局安装节点模块?

[英]How to install node modules globally?

I have zero experience with npm other than knowing it exists. 除了知道npm的存在之外,我对npm的经验为零。 I believe I have managed to install uglify, but I have no idea how to use it. 我相信我已经成功安装了uglify,但我不知道如何使用它。 I had until recently been using Yuicompressor which had a java cli. 直到最近我一直在使用具有Java cli的Yuicompressor。 How can I do something similar with uglify on a Windows 7 environment? 在Windows 7环境中,如何使用uglify做类似的事情?

Unless there is a step I skipped, the command line tools details the arguements, but my attempts to try such fail. 除非我跳过了某个步骤,否则命令行工具将详细说明争论,但是我尝试进行此类尝试的尝试将失败。

https://github.com/mishoo/UglifyJS https://github.com/mishoo/UglifyJS

C:\Data\Websites\local\htdocs\b>npm install uglify-js
uglify-js@2.7.0 node_modules\uglify-js
├── uglify-to-browserify@1.0.2
├── async@0.2.10
├── source-map@0.5.6
└── yargs@3.10.0 (decamelize@1.2.0, camelcase@1.2.1, window-size@0.1.0, cliui@2.
1.0)

C:\Data\Websites\local\htdocs\b>uglify
'uglify' is not recognized as an internal or external command,
operable program or batch file.

Anyone care to advise? 有人在乎建议吗?

To run it from the command line, you have to install it globally 要从命令行运行它,必须全局安装

C:\Data\Websites\local\htdocs\b>npm install uglify-js -g

Also, the name of the executable is uglifyjs 另外,可执行文件的名称是uglifyjs

C:\Data\Websites\local\htdocs\b>uglifyjs

Even though you installed the package uglify-js, to actually use it, it is: uglifyjs. 即使您安装了uglify-js软件包,但实际上要使用它,它是:uglifyjs。 So using your example, it would be something like: 因此,以您的示例为例:

C:\Data\Websites\local\htdocs\b>uglifyjs [ options... ] [ filename ]

Where options are parameters like: --compress , and a filename would be whatever JS file you want to uglify. 其中的选项是参数,例如:-- --compress ,文件名就是您要丑化的任何JS文件。 eg uglifyjs --compress --mangle -- input.js 例如uglifyjs --compress --mangle -- input.js

存储库的自述文件中有一个“用法”部分。

uglifyjs [ options... ] [ filename ]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM