Pengwin: Hide path to n and npm on Windows during install on WSL to avoid conflict

Created on 11 Apr 2019  Â·  16Comments  Â·  Source: WhitewaterFoundry/Pengwin

Describe the bug
It seems that because I already have NPM in the path of my Windows host (as WSL apparently copies the path of Windows tools), n refuses to install NodeJS.

To Reproduce
Steps to reproduce the behavior:

  1. Install npm on Windows, making sure that it is in the path.
  2. Start Pengwin
  3. Run pengwin-setup and go through startup screens and login
  4. Choose programming, then NodeJS
  5. Say yes to installing NodeJS using n
  6. Say no or yes to installing Yarn (doesn't matter)
  7. End pengwin-setup and check output and/or try to run node or npm.

Expected behavior
node and npm installed, running them uses the version in Pengwin

Actual behavior
Installation fails with

n-install: ERROR:
  Aborting, because n and/or Node.js-related binaries are already
  in the $PATH:

         /mnt/c/nvm/v10.13.0/npm

  Please remove any existing n, Node.js installation, then try
  again.

and the linux version of node and npm is obviously missing, making attempts to run either fail.

(BTW, your issue template is missing this Actual behavior section)

Additional context
Workaround: Remove npm from the path.

The base problem seems to be that n is rather picky with these thing. I'm not sure if that is fixable, though. To me, nvm seems like a better option (OTOH, I haven't really tested nvm for this issue, so it might be just as bad here, but in general it just works).

~(To make matters worse, it seems even if n installs correctly, the PATH isn't adjusted properly, so you need to find out where it dumped the install)~ (edit: It seems it does actually add it to .bashrc, just not to the running shell)

Basic Troubleshooting Checklist

The rest is not really relevant. It's easily fixable, but it is a really, _really_ clumsy experience. Especially since first-time setup is likely among a lot of other packages, so you won't really see the problem, and get confused since the npm that will run is really the Windows one, making it fail with a semi-cryptic error message.

Pengwin Version
1.2.3.0

Windows Build
OS Name: Microsoft Windows 10 Pro
OS Version: 10.0.17134 N/A Build 17134

Bug Patched Undergoing Testing

Most helpful comment

Hello,

The last commit of https://github.com/WhitewaterFoundry/pengwin-setup/pull/167 has the fix for this. Basically the @fishstick22 solution in an automated and generic way.

Regards

All 16 comments

Sharing PATH between Windows and Linux is a feature of WSL. We are going to have to think carefully about how we solve this without breaking other things. We could truncate Windows nodejs from PATH on install, but you're going to later have two nodejs in your PATH. We could truncate similarly on each Pengwin launch but there'd be no way to restore it when you closed Pengwin. A lot of our users are probably going to have nodejs already installed on Windows, so we need to think on this.

Putting the n bin path before the paths imported from Windows should work fine. Then the n/Pengwin-installed npm and node will be found first.

I don't think it's even possible to share the other way (from Pengwin/WSL back to Windows), so I don't believe it would conflict.

is it possible to do both a (comand -v node) and then a (node) and trap the second call's stderr to see if it's a nix or windows binary.

as a workaround I trimmed my path

PATH=$(echo "$PATH" | sed -e 's/\/mnt\/c\/Program Files\/nodejs://')
PATH=$(echo "$PATH" | sed -e 's/\/mnt\/c\/Users\/jburkholder\/AppData\/Roaming\/npm://')
PATH=$(echo "$PATH" | sed -e 's/\/mnt\/c\/Program Files (x86)\/Yarn\/bin://')

YMMV

We can ask the user before installing node if we find it in windows path to override this every time that pengwin starts

All the Linux paths should appear before Windows paths. They both should be there (because having Windows interop is nice) and if node is installed on Windows already and is getting installed in WSL, simply edit the path to ensure the WSL path of node is read prior to the path to Windows for install, as mentioned above, simply truncate the Windows paths and undo when install is complete. That override option would probably be a good idea to alert the user of potential conflict in case the Path doesn't get fixed.

I'm having the same issue :(

Hello,

The last commit of https://github.com/WhitewaterFoundry/pengwin-setup/pull/167 has the fix for this. Basically the @fishstick22 solution in an automated and generic way.

Regards

Moved into development branch.

nodejs in my PATH env has / at the end of it, so this sed isn't removing it from PATH while trying to install n.

Hello,

This commit
https://github.com/WhitewaterFoundry/pengwin-setup/commit/cea92cd2438e522d1d81accc43e6884e8d762b62
fixes the issue with the slashes.

It will be released this week.

Regards,
Carlos

El dom., 23 de junio de 2019 22:51, Jordan Janzen notifications@github.com
escribió:

nodejs in my PATH env has / at the end of it, so this sed isn't removing
it from PATH while trying to install n.

—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/WhitewaterFoundry/Pengwin/issues/400?email_source=notifications&email_token=ACACEQZCIHKFHUF4HOSWGNDP37O5ZA5CNFSM4HFDUXD2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODYLGYII#issuecomment-504785953,
or mute the thread
https://github.com/notifications/unsubscribe-auth/ACACEQ6YZIGK6RADWW6G4WTP37O5ZANCNFSM4HFDUXDQ
.

This seems to be related to what I'm seeing on my installation.
Windows 10 Pro
Version 1903
Pengwin version 1.2.5
In Pengwin, after trying to install node and npm, I get this warning:
/mnt/c/Program Files/nodejs/npm: 6: /mnt/c/Program Files/nodejs/npm: Syntax error: word unexpected (expecting "in")

I do have node and npm previously installed on Windows
node v12.3.1
npm v6.9.0

Hello @darrell24015 ,

With the latest pengwin-setup it should take care of the Windows installation of node. Try again with the latest pengwin-setup. If it still doesn't please run it again passing --debug and send us the output to check.

Regards

I'm getting an error when I try to install Node on Pengwin. It asks me if I want to hid Node on Windows and I say yes. I always get this error:
`n-install: ERROR:
Aborting, because n and/or Node.js-related binaries are already
in the $PATH:

     /mnt/c/Users/Brian/AppData/Roaming/npm/npm

Please remove any existing n, Node.js installation, then try
again.`
I'm not very experienced with WSL so I'd appreciate some help.

Here is my complete debug output.

`Running in debug/verbose mode
++ shift
++ [[ 0 -gt 0 ]]
++ wslpath 'C:\'
+++ cmd-exe /c 'echo %HOMEDRIVE%%HOMEPATH%'
+++ tr -d '\r'
++ readonly 'wHomeWinPath=C:\Users\Brian'
++ wHomeWinPath='C:\Users\Brian'
+++ wslpath -u 'C:\Users\Brian'
++ readonly wHome=/mnt/c/Users/Brian
++ wHome=/mnt/c/Users/Brian
++ readonly CANCELLED=CANCELLED
++ CANCELLED=CANCELLED
++ SetupDir=/usr/local/pengwin-setup.d
++ readonly GOVERSION=1.12
++ GOVERSION=1.12

  • declare CANCELLED
  • declare SKIP_UPDATES
  • WelcomePrompt
  • whiptail --title 'Welcome to Pengwin' --msgbox 'Thank you for supporting sustainable independent open source development.n
    Pengwin comes with a core set of useful packages pre-installed, such as curl, git, and wslu.n
    pengwin-setup allows you to install additional hand-curated selections for Pengwin and configure optional WSL-specific settings. n
    Many more packages are available via the apt package manager and optional pip, npm, and RubyGems package managers.' 17 80
  • continue_prompt
  • confirm --title 'Continue setup?' --yesno 'Would you like to continue pengwin-setup?' 8 45
  • [[ ! -n '' ]]
  • whiptail --title 'Continue setup?' --yesno 'Would you like to continue pengwin-setup?' 8 45
  • return 0
  • echo 'Starting pengwin-setup.'
    Starting pengwin-setup.
  • [[ ! -n '' ]]
  • check_upgrades
  • echo 'Updating package database'
    Updating package database
    ++ cat /etc/apt/sources.list
    ++ grep -c 'https://deb.debian.org/debian-security testing/updates'
  • local debian_security_ok=0
  • [[ 0 != 0 ]]
  • sudo apt-get update --allow-releaseinfo-change
    Hit:1 https://dl.yarnpkg.com/debian stable InRelease
    Ign:2 http://ppa.launchpad.net/brightbox/ruby-ng/ubuntu eoan InRelease
    Hit:4 https://packages.microsoft.com/repos/vscode stable InRelease
    Err:10 http://ppa.launchpad.net/brightbox/ruby-ng/ubuntu eoan Release
    404 Not Found [IP: 91.189.95.83 80]
    Hit:5 https://packagecloud.io/whitewaterfoundry/pengwin-base/debian buster InRelease
    Hit:11 https://packagecloud.io/whitewaterfoundry/pengwin-setup/debian buster InRelease
    Hit:12 https://packagecloud.io/whitewaterfoundry/wslu/debian buster InRelease
    Hit:3 https://cdn-aws.deb.debian.org/debian testing InRelease
    Hit:6 https://cdn-aws.deb.debian.org/debian testing-updates InRelease
    Hit:7 https://cdn-aws.deb.debian.org/debian-security testing-security InRelease
    Hit:8 https://cdn-aws.deb.debian.org/debian unstable InRelease
    Hit:9 https://cdn-aws.deb.debian.org/debian stable InRelease
    Reading package lists... Done
    E: The repository 'http://ppa.launchpad.net/brightbox/ruby-ng/ubuntu eoan Release' does not have a Release file.
    N: Updating from such a repository can't be done securely, and is therefore disabled by default.
    N: See apt-secure(8) manpage for repository creation and user configuration details.
  • [[ -f /etc/apt/.dist-upgrade ]]
  • echo 'Running upgrade check...'
    Running upgrade check...
    ++ sudo apt-get upgrade --show-upgraded --assume-no
    ++ grep pengwin
  • local upgrd_check=
  • [[ '' == \pen\g\w\in ]]
  • echo 'Holding pengwin-base & pengwin-setup to ensure no changes while operating'
    Holding pengwin-base & pengwin-setup to ensure no changes while operating
  • sudo apt-mark hold pengwin-base pengwin-setup
  • install_menu --debug
    ++ menu --title pengwin-setup --checklist --separate-output 'nHand-curated add-ons [SPACE to select, ENTER to confirm]:' 16 99 8 EDITORS 'Install text editors neovim, emacs, or Visual Studio Code (requires X) ' off GUI 'Install an X server or various other GUI applications' off MAINTENANCE 'Various maintenance
    tasks like home backup' off PROGRAMMING 'Install various programming languages support' off SERVICES 'Enable services support (SSH, rc.local)' off SETTINGS 'Change various settings in Pengwin' off TOOLS 'Install applications or servers' off UNINSTALL 'Uninstall applications and packages installed by pengwin-setup'
    off
    ++ local menu_choice
    +++ whiptail --title pengwin-setup --checklist --separate-output 'nHand-curated add-ons [SPACE to select, ENTER to confirm]:' 16 99 8 EDITORS 'Install text editors neovim, emacs, or Visual Studio Code (requires X) ' off GUI 'Install an X server or various other GUI applications' off MAINTENANCE 'Various maintenance tasks like home backup' off PROGRAMMING 'Install various programming languages support' off SERVICES 'Enable services support (SSH, rc.local)' off SETTINGS 'Change various settings in Pengwin' off TOOLS 'Install applications or servers' off UNINSTALL 'Uninstall applications and packages installed by pengwin-setup' off
    ++ menu_choice=PROGRAMMING
    ++ local exit_status=0
    ++ [[ 0 != 0 ]]
    ++ [[ -z PROGRAMMING ]]
    ++ echo PROGRAMMING
  • local menu_choice=PROGRAMMING
  • echo Selected: PROGRAMMING
    Selected: PROGRAMMING
  • [[ PROGRAMMING == \C\A\N\C\E\L\L\E\D ]]
  • local exit_status
  • [[ PROGRAMMING == \E\D\I\T\O\R\S ]]
  • [[ PROGRAMMING == \G\U\I ]]
  • [[ PROGRAMMING == \M\A\I\N\T\E\N\A\N\C\E ]]
  • [[ PROGRAMMING == \P\R\O\G\R\A\M\M\I\N\G ]]
  • echo PROGRAMMING
    PROGRAMMING
  • bash /usr/local/pengwin-setup.d/programming.sh --debug
    Running in debug/verbose mode
    ++ shift
    ++ [[ 0 -gt 0 ]]
    ++ wslpath 'C:\'
    +++ cmd-exe /c 'echo %HOMEDRIVE%%HOMEPATH%'
    +++ tr -d '\r'
    ++ readonly 'wHomeWinPath=C:\Users\Brian'
    ++ wHomeWinPath='C:\Users\Brian'
    +++ wslpath -u 'C:\Users\Brian'
    ++ readonly wHome=/mnt/c/Users/Brian
    ++ wHome=/mnt/c/Users/Brian
    ++ readonly CANCELLED=CANCELLED
    ++ CANCELLED=CANCELLED
    ++ SetupDir=/usr/local/pengwin-setup.d
    ++ readonly GOVERSION=1.12
    ++ GOVERSION=1.12
  • declare SetupDir
  • main --debug
    ++ menu --title 'Programming Menu' --checklist --separate-output 'Install various programming languages supportn[SPACE to select, ENTER to confirm]:' 16 95 10 C++ 'Install support for Linux C/C++ programming in Visual Studio and CLion ' off DOTNET 'Install .NET Core SDK from Microsoft and optionally install NuGet ' off GO 'Install the latest Go from Google' off JAVA 'Install the SDKMan to manage Java SDKs' off JOOMLA 'Install development support for Joomla' off LATEX 'Install TexLive for LaTeX Support' off NODEJS 'Install Node.js and npm' off PYTHONPI 'Install Python 3.7 and download and install latest PyPi' off RUBY 'Install Ruby using rbenv and optionally install Rails' off RUST 'Install latest version of Rust via rustup installer' off
    ++ local menu_choice
    +++ whiptail --title 'Programming Menu' --checklist --separate-output 'Install various programming languages supportn[SPACE to select, ENTER to confirm]:' 16 95 10 C++ 'Install support for Linux C/C++ programming in Visual Studio and CLion ' off DOTNET 'Install .NET Core SDK from Microsoft and optionally install
    NuGet ' off GO 'Install the latest Go from Google' off JAVA 'Install the SDKMan to manage Java SDKs' off JOOMLA 'Install development support for Joomla' off LATEX 'Install TexLive for LaTeX Support' off NODEJS 'Install Node.js and npm' off PYTHONPI 'Install Python 3.7 and download and install latest PyPi' off RUBY 'Install Ruby using rbenv and optionally install Rails' off RUST 'Install latest version of Rust via rustup installer' off
    ++ menu_choice=NODEJS
    ++ local exit_status=0
    ++ [[ 0 != 0 ]]
    ++ [[ -z NODEJS ]]
    ++ echo NODEJS
  • local menu_choice=NODEJS
  • [[ NODEJS == \C\A\N\C\E\L\L\E\D ]]
  • [[ NODEJS == \C++ ]]
  • [[ NODEJS == \D\O\T\N\E\T ]]
  • [[ NODEJS == \G\O ]]
  • [[ NODEJS == \J\A\V\A ]]
  • [[ NODEJS == \J\O\O\M\L\A ]]
  • [[ NODEJS == \L\A\T\E\X ]]
  • [[ NODEJS == \N\O\D\E\J\S ]]
  • echo NODE
    NODE
  • bash /usr/local/pengwin-setup.d/nodejs.sh --debug
    Running in debug/verbose mode
    ++ shift
    ++ [[ 0 -gt 0 ]]
    ++ wslpath 'C:\'
    +++ cmd-exe /c 'echo %HOMEDRIVE%%HOMEPATH%'
    +++ tr -d '\r'
    ++ readonly 'wHomeWinPath=C:\Users\Brian'
    ++ wHomeWinPath='C:\Users\Brian'
    +++ wslpath -u 'C:\Users\Brian'
    ++ readonly wHome=/mnt/c/Users/Brian
    ++ wHome=/mnt/c/Users/Brian
    ++ readonly CANCELLED=CANCELLED
    ++ CANCELLED=CANCELLED
    ++ SetupDir=/usr/local/pengwin-setup.d
    ++ readonly GOVERSION=1.12
    ++ GOVERSION=1.12
  • [[ ! -n '' ]]
  • whiptail --title NODE --yesno 'Would you like to download and install NodeJS using n and the npm package manager?' 8 88
  • echo 'Installing NODE'
    Installing NODE
  • createtmp
  • echo 'Saving current directory as $CURDIR'
    Saving current directory as $CURDIR
    ++ pwd
  • CURDIR=/mnt/c/Users/Brian
    ++ mktemp -d
  • TMPDIR=/tmp/tmp.MVFS2eJIbK
  • echo 'Going to $TMPDIR: /tmp/tmp.MVFS2eJIbK'
    Going to $TMPDIR: /tmp/tmp.MVFS2eJIbK
  • cd /tmp/tmp.MVFS2eJIbK
  • echo 'Look for Windows version of npm'
    Look for Windows version of npm
  • NPM_WIN_PROFILE=/etc/profile.d/rm-win-npm-path.sh
  • NPM_PROFILE=/etc/profile.d/n-prefix.sh
    ++ which npm
    ++ wslpath 'C:\'
  • [[ /mnt/c/Program Files/nodejs/npm == /mnt/c/* ]]
    +++ which npm
    ++ wslpath -m '/mnt/c/Program Files/nodejs/npm'
  • confirm --title 'npm in Windows' --yesno 'npm is already installed in Windows in "C:/Program Files/nodejs/npm".nnWould you still want to install the Linux version? This will hide the Windows version inside Pengwin.' 12 80
  • [[ ! -n '' ]]
  • whiptail --title 'npm in Windows' --yesno 'npm is already installed in Windows in "C:/Program Files/nodejs/npm".nnWould you still want to install the Linux version? This will hide the Windows version inside Pengwin.' 12 80
  • return 0
  • sudo tee /etc/profile.d/rm-win-npm-path.sh

Check if we have Windows Path

if ( which cmd.exe >/dev/null ); then
WIN_NPM_PATH="$(dirname "$(which npm)")"
WIN_C_PATH="$(wslpath 'C:\')"

if [[ "${WIN_NPM_PATH}" == "${WIN_C_PATH}"* ]]; then
PATH=$(echo "${PATH}" | sed -e "s#${WIN_NPM_PATH}##")
fi

WIN_YARN_PATH="$(dirname "$(which yarn)")"
if [[ "${WIN_YARN_PATH}" == "${WIN_C_PATH}"* ]]; then
PATH=$(echo "${PATH}" | sed -e "s#${WIN_YARN_PATH}##")
fi
fi
++ cat /etc/profile.d/rm-win-npm-path.sh

  • eval '

Check if we have Windows Path

if ( which cmd.exe >/dev/null ); then
WIN_NPM_PATH="$(dirname "$(which npm)")"
WIN_C_PATH="$(wslpath '\''C:\'\'')"

if [[ "${WIN_NPM_PATH}" == "${WIN_C_PATH}"* ]]; then
PATH=$(echo "${PATH}" | sed -e "s#${WIN_NPM_PATH}##")
fi

WIN_YARN_PATH="$(dirname "$(which yarn)")"
if [[ "${WIN_YARN_PATH}" == "${WIN_C_PATH}"* ]]; then
PATH=$(echo "${PATH}" | sed -e "s#${WIN_YARN_PATH}##")
fi
fi'
++ which cmd.exe
++++ which npm
+++ dirname '/mnt/c/Program Files/nodejs/npm'
++ WIN_NPM_PATH='/mnt/c/Program Files/nodejs'
+++ wslpath 'C:\'
++ WIN_C_PATH=/mnt/c/
++ [[ /mnt/c/Program Files/nodejs == /\mn\t/\c/* ]]
+++ echo '/home/brian/.pyenv/plugins/pyenv-virtualenv/shims:/home/brian/.pyenv/shims:/home/brian/.pyenv/bin:/home/brian/.rbenv/plugins/ruby-build/bin:/home/brian/.rbenv/shims:/home/brian/.rbenv/bin:/home/brian/go//bin:/usr/local/go/bin:/usr/local/go/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/mnt/c/Program Files (x86)/Intel/Intel(R) Management Engine Components/iCLS:/mnt/c/Program Files/Intel/Intel(R) Management Engine Components/iCLS:/mnt/c/Windows/System32:/mnt/c/Windows:/mnt/c/Windows/System32/wbem:/mnt/c/Windows/System32/WindowsPowerShell/v1.0:/mnt/c/Program Files (x86)/Intel/Intel(R) Management Engine Components/DAL:/mnt/c/Program Files/Intel/Intel(R) Management Engine Components/DAL:/mnt/c/Program Files (x86)/Intel/Intel(R) Management Engine Components/IPT:/mnt/c/Program Files/Intel/Intel(R) Management Engine Components/IPT:/mnt/c/Program Files (x86)/NVIDIA Corporation/PhysX/Common:/mnt/c/Windows/System32:/mnt/c/Windows:/mnt/c/Windows/System32/wbem:/mnt/c/Windows/System32/WindowsPowerShell/v1.0:/mnt/c/Windows/System32/OpenSSH:/mnt/c/Program Files/Git/cmd:/mnt/c/Program Files/PuTTY:/mnt/c/Program Files (x86)/Plantronics/Spokes3G:/mnt/c/Program Files/Intel/WiFi/bin:/mnt/c/Program Files/Common Files/Intel/WirelessCommon:/mnt/c/Program Files/nodejs:/mnt/c/Ruby25-x64/bin:/mnt/c/Users/Brian/AppData/Local/Yarn/config/global/node_modules/.bin:/mnt/c/Users/Brian/AppData/Roaming/Composer/vendor/bin:/mnt/d/Laragon/bin:/mnt/d/Laragon/bin/apache/httpd-2.4.35-win64-VC15/bin:/mnt/d/Laragon/bin/composer:/mnt/d/Laragon/bin/laragon/utils:/mnt/d/Laragon/bin/mysql/mysql-5.7.24-winx64/bin:/mnt/d/Laragon/bin/nginx/nginx-1.14.0:/mnt/d/Laragon/bin/ngrok:/mnt/d/Laragon/bin/notepad++:/mnt/d/Laragon/bin/php/php-7.2.11-Win32-VC15-x64:/mnt/d/Laragon/bin/putty:/mnt/d/Laragon/bin/redis/redis-x64-3.2.100:/mnt/d/Laragon/bin/telnet:/mnt/d/Laragon/usr/bin:/mnt/c/Users/Brian/AppData/Local/Microsoft/WindowsApps:/mnt/c/Program Files/JetBrains/PhpStorm 2019.1/bin:/mnt/c/Users/Brian/AppData/Local/Programs/Microsoft VS Code/bin:/mnt/c/Users/Brian/AppData/Local/hyper/app-3.0.2/resources/bin:/mnt/c/Users/Brian/AppData/Roaming/npm:/home/brian/n/bin'
+++ sed -e 's#/mnt/c/Program Files/nodejs##'
++ PATH='/home/brian/.pyenv/plugins/pyenv-virtualenv/shims:/home/brian/.pyenv/shims:/home/brian/.pyenv/bin:/home/brian/.rbenv/plugins/ruby-build/bin:/home/brian/.rbenv/shims:/home/brian/.rbenv/bin:/home/brian/go//bin:/usr/local/go/bin:/usr/local/go/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/mnt/c/Program Files (x86)/Intel/Intel(R) Management Engine Components/iCLS:/mnt/c/Program Files/Intel/Intel(R) Management Engine Components/iCLS:/mnt/c/Windows/System32:/mnt/c/Windows:/mnt/c/Windows/System32/wbem:/mnt/c/Windows/System32/WindowsPowerShell/v1.0:/mnt/c/Program Files (x86)/Intel/Intel(R) Management Engine Components/DAL:/mnt/c/Program Files/Intel/Intel(R) Management Engine Components/DAL:/mnt/c/Program Files (x86)/Intel/Intel(R) Management Engine Components/IPT:/mnt/c/Program Files/Intel/Intel(R) Management Engine Components/IPT:/mnt/c/Program Files (x86)/NVIDIA Corporation/PhysX/Common:/mnt/c/Windows/System32:/mnt/c/Windows:/mnt/c/Windows/System32/wbem:/mnt/c/Windows/System32/WindowsPowerShell/v1.0:/mnt/c/Windows/System32/OpenSSH:/mnt/c/Program Files/Git/cmd:/mnt/c/Program Files/PuTTY:/mnt/c/Program Files (x86)/Plantronics/Spokes3G:/mnt/c/Program Files/Intel/WiFi/bin:/mnt/c/Program Files/Common Files/Intel/WirelessCommon::/mnt/c/Ruby25-x64/bin:/mnt/c/Users/Brian/AppData/Local/Yarn/config/global/node_modules/.bin:/mnt/c/Users/Brian/AppData/Roaming/Composer/vendor/bin:/mnt/d/Laragon/bin:/mnt/d/Laragon/bin/apache/httpd-2.4.35-win64-VC15/bin:/mnt/d/Laragon/bin/composer:/mnt/d/Laragon/bin/laragon/utils:/mnt/d/Laragon/bin/mysql/mysql-5.7.24-winx64/bin:/mnt/d/Laragon/bin/nginx/nginx-1.14.0:/mnt/d/Laragon/bin/ngrok:/mnt/d/Laragon/bin/notepad++:/mnt/d/Laragon/bin/php/php-7.2.11-Win32-VC15-x64:/mnt/d/Laragon/bin/putty:/mnt/d/Laragon/bin/redis/redis-x64-3.2.100:/mnt/d/Laragon/bin/telnet:/mnt/d/Laragon/usr/bin:/mnt/c/Users/Brian/AppData/Local/Microsoft/WindowsApps:/mnt/c/Program Files/JetBrains/PhpStorm 2019.1/bin:/mnt/c/Users/Brian/AppData/Local/Programs/Microsoft VS Code/bin:/mnt/c/Users/Brian/AppData/Local/hyper/app-3.0.2/resources/bin:/mnt/c/Users/Brian/AppData/Roaming/npm:/home/brian/n/bin'
++++ which yarn
+++ dirname ''
++ WIN_YARN_PATH=.
++ [[ . == /\mn\t/\c/* ]]

  • echo 'Ensuring we have build-essential installed'
    Ensuring we have build-essential installed
  • sudo apt-get -y -q install build-essential
    Reading package lists...
    Building dependency tree...
    Reading state information...
    build-essential is already the newest version (12.6).
    0 upgraded, 0 newly installed, 0 to remove and 118 not upgraded.
  • echo 'Installing n, Node.js version manager'
    Installing n, Node.js version manager
  • curl -L https://git.io/n-install -o n-install.sh
    % Total % Received % Xferd Average Speed Time Time Time Current
    Dload Upload Total Spent Left Speed
    0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
    100 39430 100 39430 0 0 48499 0 --:--:-- --:--:-- --:--:-- 48499
    ++ which bash
  • env SHELL=/bin/bash bash n-install.sh -y
    n-install: ERROR:
    Aborting, because n and/or Node.js-related binaries are already
    in the $PATH:
     /mnt/c/Users/Brian/AppData/Roaming/npm/npm

Please remove any existing n, Node.js installation, then try
again.

++ cat /home/brian/.bashrc
++ grep '^.N_PREFIX.$'
++ cut -d# -f 1

  • N_PATH=
  • echo ''
  • sudo tee /etc/profile.d/n-prefix.sh
  • eval ''
    ++ sudo cat /etc/sudoers
    ++ grep secure_path
    ++ sed 's/(^.secure_path=")(.)(")/\2/'
  • SUDO_PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
  • echo 'Defaults secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/home/brian/n/bin"'
  • sudo 'EDITOR=tee ' visudo --quiet --file=/etc/sudoers.d/npm-path
    Defaults secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/home/brian/n/bin"
  • echo 'Installing latest node.js release'
    Installing latest node.js release
  • n latest
    /usr/local/pengwin-setup.d/nodejs.sh: line 74: n: command not found
  • echo 'Installing npm'
    Installing npm
  • curl -0 -L https://npmjs.com/install.sh -o install.sh
    % Total % Received % Xferd Average Speed Time Time Time Current
    Dload Upload Total Spent Left Speed
    0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
    100 5450 100 5450 0 0 17580 0 --:--:-- --:--:-- --:--:-- 17580
  • sh install.sh
    npm cannot be installed without node.js.
    Install node first, and then try again.

Maybe node is installed, but not in the PATH?
Note that running as sudo can change envs.

PATH=/home/brian/.pyenv/plugins/pyenv-virtualenv/shims:/home/brian/.pyenv/shims:/home/brian/.pyenv/bin:/home/brian/.rbenv/plugins/ruby-build/bin:/home/brian/.rbenv/shims:/home/brian/.rbenv/bin:/home/brian/go//bin:/usr/local/go/bin:/usr/local/go/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/mnt/c/Program Files (x86)/Intel/Intel(R) Management Engine Components/iCLS:/mnt/c/Program Files/Intel/Intel(R) Management Engine Components/iCLS:/mnt/c/Windows/System32:/mnt/c/Windows:/mnt/c/Windows/System32/wbem:/mnt/c/Windows/System32/WindowsPowerShell/v1.0:/mnt/c/Program Files (x86)/Intel/Intel(R) Management Engine Components/DAL:/mnt/c/Program Files/Intel/Intel(R) Management Engine Components/DAL:/mnt/c/Program Files (x86)/Intel/Intel(R) Management Engine Components/IPT:/mnt/c/Program Files/Intel/Intel(R) Management Engine Components/IPT:/mnt/c/Program Files (x86)/NVIDIA Corporation/PhysX/Common:/mnt/c/Windows/System32:/mnt/c/Windows:/mnt/c/Windows/System32/wbem:/mnt/c/Windows/System32/WindowsPowerShell/v1.0:/mnt/c/Windows/System32/OpenSSH:/mnt/c/Program Files/Git/cmd:/mnt/c/Program Files/PuTTY:/mnt/c/Program Files (x86)/Plantronics/Spokes3G:/mnt/c/Program Files/Intel/WiFi/bin:/mnt/c/Program Files/Common Files/Intel/WirelessCommon::/mnt/c/Ruby25-x64/bin:/mnt/c/Users/Brian/AppData/Local/Yarn/config/global/node_modules/.bin:/mnt/c/Users/Brian/AppData/Roaming/Composer/vendor/bin:/mnt/d/Laragon/bin:/mnt/d/Laragon/bin/apache/httpd-2.4.35-win64-VC15/bin:/mnt/d/Laragon/bin/composer:/mnt/d/Laragon/bin/laragon/utils:/mnt/d/Laragon/bin/mysql/mysql-5.7.24-winx64/bin:/mnt/d/Laragon/bin/nginx/nginx-1.14.0:/mnt/d/Laragon/bin/ngrok:/mnt/d/Laragon/bin/notepad++:/mnt/d/Laragon/bin/php/php-7.2.11-Win32-VC15-x64:/mnt/d/Laragon/bin/putty:/mnt/d/Laragon/bin/redis/redis-x64-3.2.100:/mnt/d/Laragon/bin/telnet:/mnt/d/Laragon/usr/bin:/mnt/c/Users/Brian/AppData/Local/Microsoft/WindowsApps:/mnt/c/Program Files/JetBrains/PhpStorm 2019.1/bin:/mnt/c/Users/Brian/AppData/Local/Programs/Microsoft VS Code/bin:/mnt/c/Users/Brian/AppData/Local/hyper/app-3.0.2/resources/bin:/mnt/c/Users/Brian/AppData/Roaming/npm:/home/brian/n/bin

Hello Brian,

It looks like you have npm installed on two places on Windows, but I need to check more deeply. I'll come back later.

Regards

In my installation, c/Users/Brian/AppData/Roaming/npm/ is empty, but in yours, you have npm installed. Try to delete one of your npm installations in Windows.

I made a fix t take account more than one installation of npm in Windows: https://github.com/WhitewaterFoundry/pengwin-setup/pull/190

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ket000 picture ket000  Â·  5Comments

camilorojasguzman picture camilorojasguzman  Â·  4Comments

Photonico picture Photonico  Â·  5Comments

laurin1 picture laurin1  Â·  4Comments

WSLUser picture WSLUser  Â·  4Comments