Linux 上的浏览​​器同步

Browsersync on Linux

我确实使用命令行在 Ubuntu 上安装了 Browsersync

npm install -g browser-sync

现在,我去查版本了:

browser-sync --version

我在哪里收到错误消息:

/usr/bin/env: node: No such file or directory

我现在该怎么办?

我在安装 nodejs-legacy 时修复了它:

sudo apt-get install nodejs-legacy

然后检查回来工作:

ihab@ihab-pc:~$ node --version
The program 'node' can be found in the following packages:
 * node
 * nodejs-legacy
Try: sudo apt-get install <selected package>
ihab@ihab-pc:~$ sudo apt-get install nodejs-legacy
[sudo] password for ihab: 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following NEW packages will be installed:
  nodejs-legacy
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 14.6 kB of archives.
After this operation, 122 kB of additional disk space will be used.
Get:1 http://eg.archive.ubuntu.com/ubuntu/ wily/universe nodejs-legacy all 0.10.25~dfsg2-2ubuntu1 [14.6 kB]
Fetched 14.6 kB in 0s (32.9 kB/s)      
Selecting previously unselected package nodejs-legacy.
(Reading database ... 232447 files and directories currently installed.)
Preparing to unpack .../nodejs-legacy_0.10.25~dfsg2-2ubuntu1_all.deb ...
Unpacking nodejs-legacy (0.10.25~dfsg2-2ubuntu1) ...
Processing triggers for man-db (2.7.4-1) ...
Setting up nodejs-legacy (0.10.25~dfsg2-2ubuntu1) ...
ihab@ihab-pc:~$ browser-sync --version
2.10.1

感谢@Biffen 的提示:)

您需要创建一个符号链接,因为 npm 安装程序不会这样做。

ln -s /usr/bin/nodejs /usr/bin/node

它记录在这里: https://nodejs.org/en/download/package-manager/

我有一个类似的问题,我通过删除有问题的现有损坏符号链接并创建一个新符号链接解决了这个问题:

  • sudo rm /usr/bin/node
  • sudo ln -s /usr/bin/nodejs /usr/bin/node

希望对某人有所帮助, 干杯