Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/458.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何在Ubuntu上从命令行运行这个html迷你程序?_Javascript_Node.js_Npm_Npm Install - Fatal编程技术网

Javascript 如何在Ubuntu上从命令行运行这个html迷你程序?

Javascript 如何在Ubuntu上从命令行运行这个html迷你程序?,javascript,node.js,npm,npm-install,Javascript,Node.js,Npm,Npm Install,我正在尝试从Ubuntu命令行运行HTML minifier。 但是当我尝试这样做的时候,我得到了一个错误 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 th

我正在尝试从Ubuntu命令行运行HTML minifier。 但是当我尝试这样做的时候,我得到了一个错误

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迷你程序似乎可行:

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)
但当我尝试运行它时,会出现以下错误:

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

为什么我不能运行html浏览器?我做错了什么?我该如何修复它呢???在ubuntu上,
node
被称为
nodejs
。我可以看到两个选择

  • 编辑文件“/usr/local/bin/html minifier”并更改
    #/usr/bin/env节点
    #/usr/bin/env节点

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


  • 或者
    ln-s/usr/bin/nodejs/usr/bin/node
    root$ html-minifier
    /usr/bin/env: node: No such file or directory