[英]How to run this html-minifier from the command-line on Ubuntu?
I'm trying to run this HTML minifier from an Ubuntu command-line. 我正在尝试从Ubuntu命令行运行此 HTML压缩程序。 But I'm getting an error when I try to do so.
但是,当我尝试这样做时出现错误。
NodeJS and NPM installs fine: NodeJS和NPM安装良好:
root$ apt-get install -y nodejs npm
Reading package lists... Done
Building dependency tree
Reading state information... Done
nodejs is already the newest version.
npm is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Installing the html-minifier seems to work: 安装html-minifier似乎可以正常工作:
root$ npm install html-minifier -g
npm http GET https://registry.npmjs.org/html-minifier
<... SNIP ...>
npm http 304 https://registry.npmjs.org/source-map
/usr/local/bin/html-minifier -> /usr/local/lib/node_modules/html-minifier/cli.js
html-minifier@3.5.9 /usr/local/lib/node_modules/html-minifier
├── commander@2.14.1
├── ncname@1.0.0 (xml-char-classes@1.0.0)
├── relateurl@0.2.7
├── he@1.1.1
├── param-case@2.1.1 (no-case@2.3.2)
├── camel-case@3.0.0 (upper-case@1.1.3, no-case@2.3.2)
├── clean-css@4.1.9 (source-map@0.5.7)
└── uglify-js@3.3.12 (source-map@0.6.1)
I can see that the html-minifier is installed: 我可以看到已安装html-minifier:
root$ which html-minifier
/usr/local/bin/html-minifier
root$ head -5 /usr/local/bin/html-minifier
#!/usr/bin/env node
/**
* html-minifier CLI tool
*
* The MIT License (MIT)
But when I try to run it, I get the following error: 但是,当我尝试运行它时,出现以下错误:
root$ html-minifier
/usr/bin/env: node: No such file or directory
Why can't I run the html-minifier? 为什么我不能运行html-minifier? What am I doing wrong?
我究竟做错了什么? And how can I fix it??
我该如何解决呢?
On ubuntu, node
is called nodejs
. 在ubuntu上,
node
称为nodejs
。 Two options I can see 我可以看到两个选择
Edit the file "/usr/local/bin/html-minifier" and change #!/usr/bin/env node
to #!/usr/bin/env nodejs
编辑文件“ / usr / local / bin / html-minifier”,并将
#!/usr/bin/env node
更改为#!/usr/bin/env nodejs
Add a small script node
to start nodejs
for you, or try alias node=nodejs
添加一个小脚本
node
为您启动nodejs
,或尝试使用alias node=nodejs
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.