• 文章介绍
  • 运行

    cnpm install
    报错

    -bash: /mnt/d/Program Files (x86)/nodejs/npm: /bin/sh^M: bad interpreter: No such file or directory

    原因:发生此问题是因为 npm 安装在您的 Windows 机器上,而不是您的 WSL 机器上。你只需要在你的 linux 机器上安装 npm 然后它就会从 linux 而不是 windows 读取二进制文件

     

    1. 打开 Ubuntu 终端

      sudo apt update

    2. 现在系统已经加速,让我们做…

      sudo apt install nodejs npm

    重新打开终端即可。

     

    或者

    sudo apt-get install curl
    curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash
    nvm ls
    nvm use 14

     

    sudo apt update && sudo apt install curl -y
    curl https://raw.githubusercontent.com/creationix/nvm/master/install.sh | bash 
    source ~/.profile 
    nvm ls-remote 
    nvm install v15 
    node --version 

    Set up Node.js on WSL 2 | Microsoft Learn

    1.本文部分内容转载自其它媒体,但并不代表本站赞同其观点和对其真实性负责。                                       2.若您需要商业运营或用于其他商业活动,请您购买正版授权并合法使用。                                          3.如果本站有侵犯、不妥之处的资源,请在网站最下方联系我们。将会第一时间解决!                                     4.本站所有内容均由互联网收集整理、网友上传,仅供大家参考、学习,不存在任何商业目的与商业用途。                            5.本站提供的所有资源仅供参考学习使用,版权归原著所有,禁止下载本站资源参与商业和非法行为,请在24小时之内自行删除!
    e搜资源 » WSL ubuntu运行npm报错 -bash: /mnt/d/Program Files (x86)/nodejs/npm: /bin/sh^M: bad interpreter: No such file or directory

    发表评论