javascript - 如何在 Ubuntu 上从命令行运行这个 html-minifier?

标签 javascript node.js npm npm-install

我正在尝试运行 this来自 Ubuntu 命令行的 HTML 压缩器。 但当我尝试这样做时出现错误。

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.

安装 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)

我可以看到 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)

但是当我尝试运行它时,出现以下错误:

root$ html-minifier
/usr/bin/env: node: No such file or directory

为什么我无法运行 html-minifier?我究竟做错了什么?我该如何解决它?

最佳答案

在 ubuntu 上,node 称为 nodejs。我可以看到两个选项

  1. 编辑文件“/usr/local/bin/html-minifier”并将 #!/usr/bin/env Node 更改为 #!/usr/bin/环境nodejs

  2. 添加一个小脚本node来为您启动nodejs,或者尝试alias node=nodejs

    <

关于javascript - 如何在 Ubuntu 上从命令行运行这个 html-minifier?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48981896/

相关文章:

npm - Axios 和 Webpack

javascript - 如何通过管道将代码和单元测试传递给 npm test?

javascript - 如何使 npm 与我的自定义 npm 包一起使用?

javascript - 在提交/部署之前检测 Browserify 损坏的构建

Javascript - 使用变量作为连接字符串访问对象节点

javascript - 如何使用 Ajax 刷新特定标签?

node.js - Node JS-检查mongoDB中是否存在字段

node.js - npm 坏了,我无法运行任何 npm 命令

javascript - 通过单击 Canvas 上的两个点绘制矩形

javascript - 单击另一个音频元素时暂停音频