npm 安装错误 `not foundram Files/nodejs/npm: 3:/mnt/c/Program Files/nodejs/npm:` [英] npm install error `not foundram Files/nodejs/npm: 3: /mnt/c/Program Files/nodejs/npm:`

查看:204
本文介绍了npm 安装错误 `not foundram Files/nodejs/npm: 3:/mnt/c/Program Files/nodejs/npm:`的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在 Windows 上安装了 Ubuntu Bash.我的 Windows 机器上的 C:\Program Files\nodejs 已经有 nodejsnpm.在 Windows 的 bash shell 中,我正在运行一个使用 npm install 命令的脚本.脚本出现以下错误

I have installed Ubuntu Bash on Windows. I already have nodejs and npm on my windows machine at C:\Program Files\nodejs. In the bash shell in Windows, I am running a script which uses npm install command. The script is giving following error

: not foundram Files/nodejs/npm: 3: /mnt/c/Program Files/nodejs/npm:
: not foundram Files/nodejs/npm: 5: /mnt/c/Program Files/nodejs/npm:
/mnt/c/Program Files/nodejs/npm: 6: /mnt/c/Program Files/nodejs/npm: Syntax error: word unexpected (expecting "in")

推荐答案

注意:在执行以下步骤之前,请先尝试重新启动 shell.

Note: Before following the steps below, first try to restart your shell.

您也可以使用 Windows PowerShell 安装 Node.js 和 NPM,因此如果您这样做了,它将无法在您的子系统中正常工作.这意味着您必须安装两次(Powershell 和子系统)或决定一件事.

You can install Node.js and NPM with your Windows PowerShell as well, so if you've done that it won't work properly for your Subsystem. That means you have to install it twice (Powershell and Subsystem) or decide on one thing.

如果前面的文字没有帮助到您,那么解决问题的方法如下:
删除您当前的安装

If the preceding text, has not helped you, this is how to solve the problem:
Remove your current installations

sudo apt-get --purge remove node
("sudo apt autoremove node" if console is asking for it)
sudo apt-get --purge remove nodejs

以正确的方式安装节点.这是针对版本 14(查看当前 LTS 版本):

Install node the right way. This is for version 14 (view current LTS version):

curl -fsSL https://deb.nodesource.com/setup_14.x | sudo -E bash -
sudo apt-get install -y nodejs

然后安装构建工具,以便稍后为 npm 安装附加组件

Then install build tools so you can install add-ons for npm later

sudo apt-get install -y build-essential

现在你可以输入了

npm -v
node -v
Same thing: nodejs -v

检查Node.js和NPM是否安装正确.如果没有显示,请重新启动外壳.

to check whether Node.js and NPM are installed correctly. If it shows nothing, restart the shell.

这里有两个链接也可以帮助您.
https://nodejs.org/en/下载/包管理器/#debian-and-ubuntu-based-linux-distributionshttps://github.com/nodesource/distributions/blob/master/README.md#debinstall

Here are two links that may also help you.
https://nodejs.org/en/download/package-manager/#debian-and-ubuntu-based-linux-distributions https://github.com/nodesource/distributions/blob/master/README.md#debinstall

另外,请查看节点版本管理器 (NVM).有了它,您可以轻松地在版本之间来回切换.

Also, take a look at the Node Version Manager (NVM). With it, you can easily switch back and forth between versions.

这篇关于npm 安装错误 `not foundram Files/nodejs/npm: 3:/mnt/c/Program Files/nodejs/npm:`的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆