New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue running npm command #1512

Closed
RichiCoder1 opened this Issue Dec 16, 2016 · 42 comments

Comments

Projects
None yet
@RichiCoder1

RichiCoder1 commented Dec 16, 2016

When running "npm" from bash, I get the following error:

richard@RICH-HOME:/mnt/c/Users/Richard$ npm
: 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")
  • Your Windows build number

    • Windows 10 Pro Insider Preview / Build 14965
  • Steps / All commands required to reproduce the error from a brand new installation

  • Strace of the failing command

richard@RICH-HOME:/mnt/c/Users/Richard$ strace npm                                                                                                                              
execve("/mnt/c/Program Files/nodejs/npm", ["npm"], [/* 15 vars */]) = 0                                                                                                         
brk(0)                                  = 0x7fffd3e7a000                                                                                                                        
access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or directory)                                                                                                 
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7ff28e0b0000                                                                                       
access("/etc/ld.so.preload", R_OK)      = -1 ENOENT (No such file or directory)                                                                                                 
open("/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3                                                                                                                                
fstat(3, {st_mode=S_IFREG|0644, st_size=18732, ...}) = 0                                                                                                                        
mmap(NULL, 18732, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7ff28e0b2000                                                                                                                
close(3)                                = 0                                                                                                                                     
access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or directory)                                                                                                 
open("/lib/x86_64-linux-gnu/libc.so.6", O_RDONLY|O_CLOEXEC) = 3                                                                                                                 
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0P \2\0\0\0\0\0"..., 832) = 832                                                                                           
fstat(3, {st_mode=S_IFREG|0755, st_size=1840928, ...}) = 0                                                                                                                      
mmap(NULL, 3949248, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7ff28da30000                                                                                      
mprotect(0x7ff28dbea000, 2097152, PROT_NONE) = 0                                                                                                                                
mmap(0x7ff28ddea000, 24576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1ba000) = 0x7ff28ddea000                                                            
mmap(0x7ff28ddf0000, 17088, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7ff28ddf0000                                                                  
close(3)                                = 0                                                                                                                                     
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7ff28e0a0000                                                                                       
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7ff28e090000                                                                                       
arch_prctl(ARCH_SET_FS, 0x7ff28e090740) = 0                                                                                                                                     
mprotect(0x7ff28ddea000, 16384, PROT_READ) = 0                                                                                                                                  
mprotect(0x7ff28e41b000, 8192, PROT_READ) = 0                                                                                                                                   
mprotect(0x7ff28e022000, 4096, PROT_READ) = 0                                                                                                                                   
munmap(0x7ff28e0b2000, 18732)           = 0                                                                                                                                     
getpid()                                = 86                                                                                                                                    
rt_sigaction(SIGCHLD, {0x7ff28e212460, ~[RTMIN RT_1], SA_RESTORER, 0x7ff28da66cb0}, NULL, 8) = 0                                                                                
geteuid()                               = 1000                                                                                                                                  
brk(0)                                  = 0x7fffd3e7a000                                                                                                                        
brk(0x7fffd3e9b000)                     = 0x7fffd3e9b000                                                                                                                        
getppid()                               = 83                                                                                                                                    
stat("/mnt/c/Users/Richard", {st_mode=S_IFDIR|0777, st_size=0, ...}) = 0                                                                                                        
stat(".", {st_mode=S_IFDIR|0777, st_size=0, ...}) = 0                                                                                                                           
open("/mnt/c/Program Files/nodejs/npm", O_RDONLY) = 3                                                                                                                           
fcntl(3, F_DUPFD, 10)                   = 10                                                                                                                                    
close(3)                                = 0                                                                                                                                     
fcntl(10, F_SETFD, FD_CLOEXEC)          = 0                                                                                                                                     
rt_sigaction(SIGINT, NULL, {SIG_DFL, [], SA_RESTORER, 0x7f5c3c426cb0}, 8) = 0                                                                                                   
rt_sigaction(SIGINT, {0x7ff28e212460, ~[RTMIN RT_1], SA_RESTORER, 0x7ff28da66cb0}, NULL, 8) = 0                                                                                 
rt_sigaction(SIGQUIT, NULL, {SIG_DFL, [], SA_RESTORER, 0x7f5c3c426cb0}, 8) = 0                                                                                                  
rt_sigaction(SIGQUIT, {SIG_DFL, ~[RTMIN RT_1], SA_RESTORER, 0x7ff28da66cb0}, NULL, 8) = 0                                                                                       
rt_sigaction(SIGTERM, NULL, {SIG_DFL, [], SA_RESTORER, 0x7f5c3c426cb0}, 8) = 0                                                                                                  
rt_sigaction(SIGTERM, {SIG_DFL, ~[RTMIN RT_1], SA_RESTORER, 0x7ff28da66cb0}, NULL, 8) = 0                                                                                       
read(10, "#!/bin/sh\r\n(set -o igncr) 2>/dev"..., 8192) = 867                                                                                                                   
clone(child_stack=0, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, child_tidptr=0x7ff28e090a10) = 87                                                                   
wait4(-1, [{WIFEXITED(s) && WEXITSTATUS(s) == 2}], 0, NULL) = 87                                                                                                                
--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=87, si_status=2, si_utime=0, si_stime=0} ---                                                                          
rt_sigreturn()                          = 87                                                                                                                                    
stat("/usr/local/sbin/\r", 0x7fffdbcd7690) = -1 ENOENT (No such file or directory)                                                                                              
stat("/usr/local/bin/\r", 0x7fffdbcd7690) = -1 ENOENT (No such file or directory)                                                                                               
stat("/usr/sbin/\r", 0x7fffdbcd7690)    = -1 ENOENT (No such file or directory)                                                                                                 
stat("/usr/bin/\r", 0x7fffdbcd7690)     = -1 ENOENT (No such file or directory)                                                                                                 
stat("/sbin/\r", 0x7fffdbcd7690)        = -1 ENOENT (No such file or directory)                                                                                                 
stat("/bin/\r", 0x7fffdbcd7690)         = -1 ENOENT (No such file or directory)                                                                                                 
stat("/usr/games/\r", 0x7fffdbcd7690)   = -1 ENOENT (No such file or directory)                                                                                                 
stat("/usr/local/games/\r", 0x7fffdbcd7690) = -1 ENOENT (No such file or directory)                                                                                             
stat("/mnt/c/Program Files/ConEmu/\r", 0x7fffdbcd7690) = -1 ENOENT (No such file or directory)                                                                                  
stat("/mnt/c/Program Files/ConEmu/ConEmu/\r", 0x7fffdbcd7690) = -1 ENOENT (No such file or directory)                                                                           
stat("/mnt/c/ProgramData/Oracle/Java/javapath/\r", 0x7fffdbcd7690) = -1 ENOENT (No such file or directory)                                                                      
stat("/mnt/c/Program Files (x86)/Razer Chroma SDK/bin/\r", 0x7fffdbcd7690) = -1 ENOENT (No such file or directory)                                                              
stat("/mnt/c/Program Files/Razer Chroma SDK/bin/\r", 0x7fffdbcd7690) = -1 ENOENT (No such file or directory)                                                                    
stat("/mnt/c/Windows/System32/\r", 0x7fffdbcd7690) = -1 ENOENT (No such file or directory)                                                                                      
stat("/mnt/c/Windows/\r", 0x7fffdbcd7690) = -1 ENOENT (No such file or directory)                                                                                               
stat("/mnt/c/Windows/System32/wbem/\r", 0x7fffdbcd7690) = -1 ENOENT (No such file or directory)                                                                                 
stat("/mnt/c/Windows/System32/WindowsPowerShell/v1.0/\r", 0x7fffdbcd7690) = -1 ENOENT (No such file or directory)                                                               
stat("/mnt/c/ProgramData/chocolatey/bin/\r", 0x7fffdbcd7690) = -1 ENOENT (No such file or directory)                                                                            
stat("/mnt/c/Program Files/Java/jdk1.8.0_112/bin/\r", 0x7fffdbcd7690) = -1 ENOENT (No such file or directory)                                                                   
stat("/mnt/c/Program Files (x86)/Skype/Phone/\r", 0x7fffdbcd7690) = -1 ENOENT (No such file or directory)                                                                       
stat("/mnt/c/Program Files/Microsoft SQL Server/120/Tools/Binn/\r", 0x7fffdbcd7690) = -1 ENOENT (No such file or directory)                                                     
stat("/mnt/c/Program Files/Microsoft SQL Server/130/Tools/Binn/\r", 0x7fffdbcd7690) = -1 ENOENT (No such file or directory)                                                     
stat("/mnt/c/Program Files (x86)/Microsoft Emulator Manager/1.0/\r", 0x7fffdbcd7690) = -1 ENOENT (No such file or directory)                                                    
stat("/mnt/c/Program Files (x86)/Windows Kits/10/Windows Performance Toolkit/\r", 0x7fffdbcd7690) = -1 ENOENT (No such file or directory)                                       
stat("/mnt/c/Program Files/Microsoft/Web Platform Installer/\r", 0x7fffdbcd7690) = -1 ENOENT (No such file or directory)                                                        
stat("/mnt/c/Program Files/Microsoft DNX/Dnvm/\r", 0x7fffdbcd7690) = -1 ENOENT (No such file or directory)                                                                      
stat("/mnt/c/Program Files/Microsoft SQL Server/Client SDK/ODBC/130/Tools/Binn/\r", 0x7fffdbcd7690) = -1 ENOENT (No such file or directory)                                     
stat("/mnt/c/Program Files (x86)/Microsoft SQL Server/130/Tools/Binn/\r", 0x7fffdbcd7690) = -1 ENOENT (No such file or directory)                                               
stat("/mnt/c/Program Files/Microsoft SQL Server/130/DTS/Binn/\r", 0x7fffdbcd7690) = -1 ENOENT (No such file or directory)                                                       
stat("/mnt/c/Program Files/TortoiseGit/bin/\r", 0x7fffdbcd7690) = -1 ENOENT (No such file or directory)                                                                         
stat("/mnt/c/Program Files/Seq/\r", 0x7fffdbcd7690) = -1 ENOENT (No such file or directory)                                                                                     
stat("/mnt/c/Program Files/Git/cmd/\r", 0x7fffdbcd7690) = -1 ENOENT (No such file or directory)                                                                                 
stat("/mnt/c/Program Files/nodejs/\r", 0x7fffdbcd7690) = -1 ENOENT (No such file or directory)                                                                                  
stat("/mnt/c/Program Files/dotnet/\r", 0x7fffdbcd7690) = -1 ENOENT (No such file or directory)                                                                                  
stat("/mnt/c/Windows/System32/\r", 0x7fffdbcd7690) = -1 ENOENT (No such file or directory)                                                                                      
stat("/mnt/c/Windows/\r", 0x7fffdbcd7690) = -1 ENOENT (No such file or directory)                                                                                               
stat("/mnt/c/Windows/System32/wbem/\r", 0x7fffdbcd7690) = -1 ENOENT (No such file or directory)                                                                                 
stat("/mnt/c/Windows/System32/WindowsPowerShell/v1.0/\r", 0x7fffdbcd7690) = -1 ENOENT (No such file or directory)                                                               
stat("/mnt/c/Program Files (x86)/Yarn/bin/\r", 0x7fffdbcd7690) = -1 ENOENT (No such file or directory)                                                                          
stat("/mnt/c/Users/Richard/.dnx/runtimes/dnx-clr-win-x86.1.0.0-rc1-update2/bin/\r", 0x7fffdbcd7690) = -1 ENOENT (No such file or directory)                                     
stat("/mnt/c/Users/Richard/AppData/Local/Microsoft/WindowsApps/\r", 0x7fffdbcd7690) = -1 ENOENT (No such file or directory)                                                     
stat("/mnt/c/Program Files (x86)/Microsoft VS Code/bin/\r", 0x7fffdbcd7690) = -1 ENOENT (No such file or directory)                                                             
stat("/mnt/c/Users/Richard/AppData/Local/.meteor/\r", 0x7fffdbcd7690) = -1 ENOENT (No such file or directory)                                                                   
stat("/mnt/c/tools/\r", 0x7fffdbcd7690) = -1 ENOENT (No such file or directory)                                                                                                 
stat("/mnt/c/Users/Richard/AppData/Roaming/npm/\r", 0x7fffdbcd7690) = -1 ENOENT (No such file or directory)                                                                     
stat("/mnt/c/Users/Richard/AppData/Local/Microsoft/WindowsApp/\r", 0x7fffdbcd7690) = -1 ENOENT (No such file or directory)                                                      
write(2, "/mnt/c/Program Files/nodejs/npm:"..., 69/mnt/c/Program Files/nodejs/npm: 3: /mnt/c/Program Files/nodejs/npm: ) = 69                                                   
: not found)           = 122                                                                                                                                                    
write(2, "\n", 1                                                                                                                                                                
)                       = 1                                                                                                                                                     
pipe([3, 4])                            = 0                                                                                                                                     
clone(child_stack=0, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, child_tidptr=0x7ff28e090a10) = 88                                                                   
close(4)                                = 0                                                                                                                                     
read(3, "/mnt/c/Program Files/nodejs\n", 128) = 28                                                                                                                              
--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=88, si_status=0, si_utime=0, si_stime=0} ---                                                                          
rt_sigreturn()                          = 28                                                                                                                                    
read(3, "", 128)                        = 0                                                                                                                                     
close(3)                                = 0                                                                                                                                     
wait4(-1, [{WIFEXITED(s) && WEXITSTATUS(s) == 0}], 0, NULL) = 88                                                                                                                
stat("/usr/local/sbin/\r", 0x7fffdbcd7690) = -1 ENOENT (No such file or directory)                                                                                              
stat("/usr/local/bin/\r", 0x7fffdbcd7690) = -1 ENOENT (No such file or directory)                                                                                               
stat("/usr/sbin/\r", 0x7fffdbcd7690)    = -1 ENOENT (No such file or directory)                                                                                                 
stat("/usr/bin/\r", 0x7fffdbcd7690)     = -1 ENOENT (No such file or directory)                                                                                                 
stat("/sbin/\r", 0x7fffdbcd7690)        = -1 ENOENT (No such file or directory)                                                                                                 
stat("/bin/\r", 0x7fffdbcd7690)         = -1 ENOENT (No such file or directory)                                                                                                 
stat("/usr/games/\r", 0x7fffdbcd7690)   = -1 ENOENT (No such file or directory)                                                                                                 
stat("/usr/local/games/\r", 0x7fffdbcd7690) = -1 ENOENT (No such file or directory)                                                                                             
stat("/mnt/c/Program Files/ConEmu/\r", 0x7fffdbcd7690) = -1 ENOENT (No such file or directory)                                                                                  
stat("/mnt/c/Program Files/ConEmu/ConEmu/\r", 0x7fffdbcd7690) = -1 ENOENT (No such file or directory)                                                                           
stat("/mnt/c/ProgramData/Oracle/Java/javapath/\r", 0x7fffdbcd7690) = -1 ENOENT (No such file or directory)                                                                      
stat("/mnt/c/Program Files (x86)/Razer Chroma SDK/bin/\r", 0x7fffdbcd7690) = -1 ENOENT (No such file or directory)                                                              
stat("/mnt/c/Program Files/Razer Chroma SDK/bin/\r", 0x7fffdbcd7690) = -1 ENOENT (No such file or directory)                                                                    
stat("/mnt/c/Windows/System32/\r", 0x7fffdbcd7690) = -1 ENOENT (No such file or directory)                                                                                      
stat("/mnt/c/Windows/\r", 0x7fffdbcd7690) = -1 ENOENT (No such file or directory)                                                                                               
stat("/mnt/c/Windows/System32/wbem/\r", 0x7fffdbcd7690) = -1 ENOENT (No such file or directory)                                                                                 
stat("/mnt/c/Windows/System32/WindowsPowerShell/v1.0/\r", 0x7fffdbcd7690) = -1 ENOENT (No such file or directory)                                                               
stat("/mnt/c/ProgramData/chocolatey/bin/\r", 0x7fffdbcd7690) = -1 ENOENT (No such file or directory)                                                                            
stat("/mnt/c/Program Files/Java/jdk1.8.0_112/bin/\r", 0x7fffdbcd7690) = -1 ENOENT (No such file or directory)                                                                   
stat("/mnt/c/Program Files (x86)/Skype/Phone/\r", 0x7fffdbcd7690) = -1 ENOENT (No such file or directory)                                                                       
stat("/mnt/c/Program Files/Microsoft SQL Server/120/Tools/Binn/\r", 0x7fffdbcd7690) = -1 ENOENT (No such file or directory)                                                     
stat("/mnt/c/Program Files/Microsoft SQL Server/130/Tools/Binn/\r", 0x7fffdbcd7690) = -1 ENOENT (No such file or directory)                                                     
stat("/mnt/c/Program Files (x86)/Microsoft Emulator Manager/1.0/\r", 0x7fffdbcd7690) = -1 ENOENT (No such file or directory)                                                    
stat("/mnt/c/Program Files (x86)/Windows Kits/10/Windows Performance Toolkit/\r", 0x7fffdbcd7690) = -1 ENOENT (No such file or directory)                                       
stat("/mnt/c/Program Files/Microsoft/Web Platform Installer/\r", 0x7fffdbcd7690) = -1 ENOENT (No such file or directory)                                                        
stat("/mnt/c/Program Files/Microsoft DNX/Dnvm/\r", 0x7fffdbcd7690) = -1 ENOENT (No such file or directory)                                                                      
stat("/mnt/c/Program Files/Microsoft SQL Server/Client SDK/ODBC/130/Tools/Binn/\r", 0x7fffdbcd7690) = -1 ENOENT (No such file or directory)                                     
stat("/mnt/c/Program Files (x86)/Microsoft SQL Server/130/Tools/Binn/\r", 0x7fffdbcd7690) = -1 ENOENT (No such file or directory)                                               
stat("/mnt/c/Program Files/Microsoft SQL Server/130/DTS/Binn/\r", 0x7fffdbcd7690) = -1 ENOENT (No such file or directory)                                                       
stat("/mnt/c/Program Files/TortoiseGit/bin/\r", 0x7fffdbcd7690) = -1 ENOENT (No such file or directory)                                                                         
stat("/mnt/c/Program Files/Seq/\r", 0x7fffdbcd7690) = -1 ENOENT (No such file or directory)                                                                                     
stat("/mnt/c/Program Files/Git/cmd/\r", 0x7fffdbcd7690) = -1 ENOENT (No such file or directory)                                                                                 
stat("/mnt/c/Program Files/nodejs/\r", 0x7fffdbcd7690) = -1 ENOENT (No such file or directory)                                                                                  
stat("/mnt/c/Program Files/dotnet/\r", 0x7fffdbcd7690) = -1 ENOENT (No such file or directory)                                                                                  
stat("/mnt/c/Windows/System32/\r", 0x7fffdbcd7690) = -1 ENOENT (No such file or directory)                                                                                      
stat("/mnt/c/Windows/\r", 0x7fffdbcd7690) = -1 ENOENT (No such file or directory)                                                                                               
stat("/mnt/c/Windows/System32/wbem/\r", 0x7fffdbcd7690) = -1 ENOENT (No such file or directory)                                                                                 
stat("/mnt/c/Windows/System32/WindowsPowerShell/v1.0/\r", 0x7fffdbcd7690) = -1 ENOENT (No such file or directory)                                                               
stat("/mnt/c/Program Files (x86)/Yarn/bin/\r", 0x7fffdbcd7690) = -1 ENOENT (No such file or directory)                                                                          
stat("/mnt/c/Users/Richard/.dnx/runtimes/dnx-clr-win-x86.1.0.0-rc1-update2/bin/\r", 0x7fffdbcd7690) = -1 ENOENT (No such file or directory)                                     
stat("/mnt/c/Users/Richard/AppData/Local/Microsoft/WindowsApps/\r", 0x7fffdbcd7690) = -1 ENOENT (No such file or directory)                                                     
stat("/mnt/c/Program Files (x86)/Microsoft VS Code/bin/\r", 0x7fffdbcd7690) = -1 ENOENT (No such file or directory)                                                             
stat("/mnt/c/Users/Richard/AppData/Local/.meteor/\r", 0x7fffdbcd7690) = -1 ENOENT (No such file or directory)                                                                   
stat("/mnt/c/tools/\r", 0x7fffdbcd7690) = -1 ENOENT (No such file or directory)                                                                                                 
stat("/mnt/c/Users/Richard/AppData/Roaming/npm/\r", 0x7fffdbcd7690) = -1 ENOENT (No such file or directory)                                                                     
stat("/mnt/c/Users/Richard/AppData/Local/Microsoft/WindowsApp/\r", 0x7fffdbcd7690) = -1 ENOENT (No such file or directory)                                                      
write(2, "/mnt/c/Program Files/nodejs/npm:"..., 69/mnt/c/Program Files/nodejs/npm: 5: /mnt/c/Program Files/nodejs/npm: ) = 69                                                   
: not found)           = 122                                                                                                                                                    
write(2, "\n", 1                                                                                                                                                                
)                       = 1                                                                                                                                                     
write(2, "/mnt/c/Program Files/nodejs/npm:"..., 69/mnt/c/Program Files/nodejs/npm: 6: /mnt/c/Program Files/nodejs/npm: ) = 69                                                   
write(2, "Syntax error: word unexpected (e"..., 46Syntax error: word unexpected (expecting "in")) = 46                                                                          
write(2, "\n", 1                                                                                                                                                                
)                       = 1                                                                                                                                                     
exit_group(2)                           = ?                                                                                                                                     
+++ exited with 2 +++                                                                                                                                                           
  • Required packages and commands to install
    • NodeJS (windows)
    • npm
@benhillis

This comment has been minimized.

Member

benhillis commented Dec 16, 2016

Interesting, I wonder why all of the paths that are being stat'ed have a '\r' character at the end... I suspect this is coming from some config file that needs to be converted to Unix line endings (probably /mnt/c/Program Files/nodejs/npm). How did you generate this file?

Could you try running dos2unix /mnt/c/Program Files/nodejs/npm and rerunning the command?

@RichiCoder1

This comment has been minimized.

RichiCoder1 commented Dec 16, 2016

Standard NPM install as far as I'm aware.

Got this fun error back:

richard@RICH-HOME:/mnt/c/Users/Richard$ sudo dos2unix /mnt/c/Program\ Files/nodejs/npm
[sudo] password for richard:
dos2unix: Failed to open temporary output file: Permission denied
dos2unix: converting file /mnt/c/Program Files/nodejs/npm to Unix format ...
dos2unix: problems converting file /mnt/c/Program Files/nodejs/npm
@benhillis

This comment has been minimized.

Member

benhillis commented Dec 16, 2016

Maybe run bash.exe elevated? The Program Files directory might be locked down to non admin users.

@RichiCoder1

This comment has been minimized.

RichiCoder1 commented Dec 16, 2016

Ah, that was it all right. Got this error now:

richard@RICH-HOME:/mnt/c/Users/Richard$ npm
module.js:472
    throw err;
    ^

Error: Cannot find module 'C:\mnt\c\Program Files\nodejs\node_modules\npm\bin\npm-cli.js'
    at Function.Module._resolveFilename (module.js:470:15)
    at Function.Module._load (module.js:418:25)
    at Module.runMain (module.js:605:10)
    at run (bootstrap_node.js:420:7)
    at startup (bootstrap_node.js:139:9)
    at bootstrap_node.js:535:3

But I'm thinking that may be a quirk of windows<->linux?

@krzysztofantczak

This comment has been minimized.

krzysztofantczak commented Dec 27, 2016

Why just not use NPM from ubuntu side? It works perfectly fine. Also, NVM works really well here.

@RichiCoder1

This comment has been minimized.

RichiCoder1 commented Dec 27, 2016

The honest answer was I was in bash shell by accident when I ran the initial command, just figured I should report it.

@bubthegreat

This comment has been minimized.

bubthegreat commented Jan 30, 2017

Just hit this issue as well - haven't found a good fix yet either. If you end up finding one that works - please post here - I will as well.

@kylemh

This comment has been minimized.

kylemh commented Mar 24, 2017

I did the node installer on Windows 10, restarted my computer, and tried running NPM with the same exact trace as @benhillis - I'm using Bash for Ubuntu via developer mode.

This feedback:

: 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")

Occurs after any usage of $ npm - regardless of the flag or instruction used in conjunction.

@chrisdhanaraj

This comment has been minimized.

chrisdhanaraj commented Apr 2, 2017

Looks like some sort of conflict between Node on Windows and Node installed inside of the subsystem. I installed both (Node on Windows to get Hyper operational) and then node on the subsystem for everything else - I kind of assumed that because the node on the subsystem was the binary being used (if I did a where node) that I wouldn't run into these problems. No dice, get the same error as everyone else

@aseering

This comment has been minimized.

Contributor

aseering commented Apr 2, 2017

@chrisdhanaraj -- could you confirm the same for npm? Specifically, if you do which npm at a bash prompt, what is printed out in response?

For what it's worth, I have npm installed in both Windows and WSL, and I don't experience this problem. For me:

$ which npm
/usr/bin/npm
@mrtopf

This comment has been minimized.

mrtopf commented Apr 2, 2017

So I now simply installed the most recent version of node like on ubuntu:

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

(the newer node version also include npm already)

More details here: https://nodejs.org/en/download/package-manager/#debian-and-ubuntu-based-linux-distributions

Now this is used inside hyper.js/bash. The windows installation is still there but basically ignored by bash.

@petetnt

This comment has been minimized.

petetnt commented May 11, 2017

I was having this issue when running zsh with oh-my-zsh inside the WSL. but changing the PATH helped.

In my ~/.bashrc

I have this script to automatically go to zsh when launching bash:

if test -t 1; then
exec zsh
fi

I installed node for the Ubuntu side too with the command above:

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

But I was still running into the same error because my which npm pointed to Program Files, while sudo which npm pointed usr/bin/npm. Exporting the correct path was the correct solution, the oh-my-zsh creates a handy configured ~/.zshrc file, which has this on top:

# If you come from bash you might have to change your $PATH.
# export PATH=$HOME/bin:/usr/local/bin:$PATH

Which I changed to the default Ubuntu one export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games and sourced the file with source ~/.zshrc and everything started working just fine.

@BurtHarris

This comment has been minimized.

BurtHarris commented May 20, 2017

Unfortunately, the very first thing I tried using wsl bash was npm install, producing the same disappointing result:

burt@SHUTTLE:~$ npm
: 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")
burt@SHUTTLE:~$ which npm
/mnt/c/Program Files/nodejs/npm

The error message really sucks. I'm guessing this is probably caused by to the space in Program Files, so I'm guessing this is likely to impact lots of programs installed on from Windows, not just npm. For someone like me who's just dabbling in bash this is a bad experience.

I'm a Windows developer through and through, but IMHO allowing spaces in directory names was one of the bigger mistakes in the Windows NT. Allowing spaces was surpassed only by including spaces in the normal names of system folders. Have I gotten burned by that again?

Is it possible to "fix" this by patching up the UNIX version of the PATH environment variable using quotes or something?

@phucanhapril

This comment has been minimized.

phucanhapril commented May 23, 2017

hi y'all, here's how i got my stuff working. i'm on ubuntu for windows 10 (on a windows VM--i don't think the VM part matters though). i was getting the same errors as @RichiCoder1

$ npm -v
: 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")

i have node installed for windows (off the nodejs site). i kept it around, and in addition i followed @mrtopf's install instructions

$ curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -
$ sudo apt-get install -y nodejs

then i made some changes to my PATH in my ~/.profile

PATH="$HOME/bin:$HOME/.local/bin:/usr/bin:$PATH"

and sourced it source ~/.profile

what i'm doing up there is telling bash where & in what order to look for my commands, separated by : so i'm saying first look in $HOME/bin then $HOME/.local/bin etc.

you should which npm and use the path where your ubuntu npm is. here's mine:

$ which npm
/usr/bin/npm

so i added /usr/bin to my PATH. /usr/bin needs to go BEFORE $PATH. i check that everything's OK now

$ whereis npm
npm: /usr/bin/npm /mnt/c/Program Files/nodejs/npm /mnt/c/Program Files/nodejs/npm.cmd

bash will use /usr/bin/npm before the npm in Program Files
now i can npm install with no problems :-)

@felipemanga

This comment has been minimized.

felipemanga commented Jun 3, 2017

Hello,

I just had this issue, and I didn't want to have a second npm install.
I fixed it by changing the line endings in the npm script and removing the ".exe" in the following line:
NODE_EXE="$basedir/node"

Next I created a "Program Files/nodejs/node" script:

#!/bin/bash

for var in "$@"
do
  if [ -e "$var" ]
  then
      var=$(echo "$var" | sed -e 's,^/mnt/\([a-z]\)/,\1:/,' | sed -e 's,/,\\,g')
  fi

  Args=("${Args[@]}" "$var")
done

node.exe "${Args[@]}"

That translates "node /mnt/c/Users/..../file.js" into "node.exe c:\users....\file.js"
To test, I ran:
npm install -g gulp (installed gulp globally, in AppData/Roaming/npm, as expected)
npm install gulp (installed gulp in project)
gulp (executed the global gulp shell script)

@hellobrian

This comment has been minimized.

hellobrian commented Jun 3, 2017

@phucanhapril your $PATH changes worked like a charm! 💯 Thank you! 👍

@yduman

This comment has been minimized.

yduman commented Jun 15, 2017

@phucanhapril you saved me a lot of time thanks! 👍

@Georg-W

This comment has been minimized.

Georg-W commented Aug 5, 2017

Just restarting the command promp after the node installation on the bash resolved this error for me.

@ranneyd

This comment has been minimized.

ranneyd commented Aug 16, 2017

@Georg-W now I feel stupid. Good call!

@jepperaskdk

This comment has been minimized.

jepperaskdk commented Sep 2, 2017

Running with sudo worked for me, when attempting to install less:

*removed*:/mnt/c/Users/Jeppe$ npm install -g less
: 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")
*removed*:/mnt/c/Users/Jeppe$ sudo !!
sudo npm install -g less
sudo: unable to resolve host DESKTOP-K3QCK34
npm http GET https://registry.npmjs.org/less
... rest of installation, which succeeded.
@murpyslaw

This comment has been minimized.

murpyslaw commented Sep 21, 2017

I've found out what causes:

: 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")

If you open

vim -b `which npm` 

you will see the probably somebody upstream messed up and forgot to turn on git config core.autoctrlf true, thus causing a BUNCH of ^M to be appended to each line.
The problem is that, even when these are removed, they are everywhere in the nodejs repo.

I'm not sure if there's any way besides using the Windows Installer to install node for now.

Edit
Actually there may be a way, now that I think about it:

cd
git clone git://git.debian.org/git/collab-maint/nodejs.git
cd nodejs
./configure --prefix /usr/bin
make
make install

I will test and see if this works

@leojh

This comment has been minimized.

leojh commented Oct 7, 2017

I uninstalled node from WIndows and then installing nvm worked fine inside of Bash for Windows

@Shipwreck

This comment has been minimized.

Shipwreck commented Dec 4, 2017

@phucanhapril solution worked for me on WSL. I also have npm installed alongside on Windows.

Thanks for the help.

@zaidrashid

This comment has been minimized.

zaidrashid commented Dec 4, 2017

@phucanhapril , correct me if I'm wrong but your solution is to install a newer NPM in the Bash environment correct?

Is there a way to maintain the node installed in Windows, while making it work on Bash too?

@Shipwreck

This comment has been minimized.

Shipwreck commented Dec 4, 2017

Hi @zaidrashid I can confirm that npm is installed in Windows and WSL. I followed @phucanhapril process.

If I open a Windows terminal and call npm I get:
npm@5.5.1 C:\Program Files\nodejs\node_modules\npm

Then I bash into WSL and call npm and get:
npm@3.10.10 /usr/lib/node_modules/npm

Am realizing now that I may have some issues with versions, but they do appear to be working independently.

@mfominov

This comment has been minimized.

mfominov commented Jan 15, 2018

Hi, i used @felipemanga solution but made modification in npm srcipt:
case uname -a |grep Microsoft in
Microsoft) NODE_EXE="$basedir/node"
;;
*)
NODE_EXE="$basedir/node.exe"
if ! [ -x "$NODE_EXE" ]; then
NODE_EXE=node
fi
;;
esac
than i have to convert npm scrip to LF, and everything works:
mfominov@MFOMINOV:/mnt/c/Users/mfominov/source$ npm -v
5.5.1

@whindes

This comment has been minimized.

whindes commented Jan 24, 2018

Hello @mfominov, I also used @felipemanga 's script but could not get the npm script to work. Here is the full npm script:

(set -o igncr) 2>/dev/null && set -o igncr; # cygwin encoding fix

basedir=`dirname "$0"`

case `uname` in
    *CYGWIN*) basedir=`cygpath -w "$basedir"`;;
esac

NODE_EXE="$basedir/node.exe"
if ! [ -x "$NODE_EXE" ]; then
  NODE_EXE=node
fi

NPM_CLI_JS="$basedir/node_modules/npm/bin/npm-cli.js"

case `uname -a` in
  *MINGW*)
    NPM_PREFIX=`"$NODE_EXE" "$NPM_CLI_JS" prefix -g`
    NPM_PREFIX_NPM_CLI_JS="$NPM_PREFIX/node_modules/npm/bin/npm-cli.js"
    if [ -f "$NPM_PREFIX_NPM_CLI_JS" ]; then
      NPM_CLI_JS="$NPM_PREFIX_NPM_CLI_JS"
    fi
    ;;
  *CYGWIN*)
    NPM_PREFIX=`"$NODE_EXE" "$NPM_CLI_JS" prefix -g`
    NPM_PREFIX_NPM_CLI_JS="$NPM_PREFIX/node_modules/npm/bin/npm-cli.js"
    if [ -f "$NPM_PREFIX_NPM_CLI_JS" ]; then
      NPM_CLI_JS="$NPM_PREFIX_NPM_CLI_JS"
    fi
    ;;
  *Microsoft*)
    NPM_PREFIX=`"$NODE_EXE" "$NPM_CLI_JS" prefix -g`
    NPM_PREFIX_NPM_CLI_JS="$NPM_PREFIX/node_modules/npm/bin/npm-cli.js"
    if [ -f "$NPM_PREFIX_NPM_CLI_JS" ]; then
      NPM_CLI_JS="$NPM_PREFIX_NPM_CLI_JS"
    fi
    ;;
esac

"$NODE_EXE" "$NPM_CLI_JS" "$@"

node -v works great, however, this is the output that I am getting for npm -v
net.js:200
this._handle.open(options.fd);
^

Error: EINVAL: invalid argument, uv_pipe_open
at new Socket (net.js:200:18)
at createWritableStdioStream (internal/process/stdio.js:164:16)
at process.getStdout [as stdout] (internal/process/stdio.js:14:14)
at console.js:246:38
at NativeModule.compile (bootstrap_node.js:596:7)
at Function.NativeModule.require (bootstrap_node.js:541:18)
at setupGlobalConsole (bootstrap_node.js:310:41)
at startup (bootstrap_node.js:70:7)
at bootstrap_node.js:608:3

@donaldpipowitch

This comment has been minimized.

donaldpipowitch commented Jan 25, 2018

In case anyone uses n instead of nvm to manage Node versions in your WSL and sees this error, you'll need to add PATH="$HOME/n/bin:$PATH" to your .bashrc so n's npm has a higher priority than /mnt/c/Program Files/nodejs/npm. 👌

@mlynch

This comment has been minimized.

mlynch commented Jan 27, 2018

This command worked for me, and I changed 6 to 8 to get the latest:

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

Also, I had to run bash again after this. I didn't need to update my profile.

@connelhooley

This comment has been minimized.

connelhooley commented Feb 17, 2018

Don't forget to close and reopen bash after running the commands to install Node. This fixed the ": not foundram Files/nodejs/npm: 3: /mnt/c/Program Files/nodejs/npm:" error for me.

@trinhvietnam

This comment has been minimized.

trinhvietnam commented Mar 15, 2018

close current terminal, then open other terminal, it will ok

@therealkenc

This comment has been minimized.

Collaborator

therealkenc commented Mar 15, 2018

This issue ended up dangling somehow. From a the OP way back:

The honest answer was I was in bash shell by accident when I ran the initial command, just figured I should report it.

Windows npm is a shell script script. Variation #2365 (message) etc. This is linux-behavior; say for example you were running in a Docker VM with a shared NTFS drive, Linux to a Windows SMB share; whatever. Folks should feel free to continue post tips and tricks, but there's no WSL actionable.

@achal126

This comment has been minimized.

achal126 commented Mar 19, 2018

Solution:

after installing nodejs

write the following in bash:

which npm
/usr/bin/npm
Add the location to the PATH environment variable
PATH=/usr/bin:$PATH

It will work.

@mathiasfoster mathiasfoster referenced this issue Apr 29, 2018

Closed

Use NPM in Hyper #2953

1 of 1 task complete
@chiragsh

This comment has been minimized.

chiragsh commented Jun 14, 2018

restarting bash after installing npm worked for me simply

@mohouyizme

This comment has been minimized.

mohouyizme commented Jun 15, 2018

@Georg-W 😮 🤦.

@vasanthdeveloper

This comment has been minimized.

vasanthdeveloper commented Aug 1, 2018

I found the solution. In the bash shell set an alias to the npm command to /usr/bin/npm and it fixed everything.

alias "npm"="/usr/bin/npm"

Thank you :)

@assetcorp

This comment has been minimized.

assetcorp commented Aug 11, 2018

I had this same issue. I resolved it by re-installing node with this command:

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

When I tried to do which npm and sudo which npm, the error persisted and I was getting /mnt/c/Program Files/nodejs/npm as response, thus I ejected from WSL and re-entered using the bash command from the windows command prompt. Everything worked and which npm returned /usr/bin/npm as expected.

@alikatkar

This comment has been minimized.

alikatkar commented Aug 14, 2018

I got a same issue. Fixed the following commands

curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
sudo apt-get install -y nodejs
source ~/.profile

@martingull

This comment has been minimized.

martingull commented Sep 13, 2018

Just restarting the command promp after the node installation on the bash resolved this error for me.

This guy is a genius. Thank you!

@jeffmartinxyz

This comment has been minimized.

jeffmartinxyz commented Oct 25, 2018

I ran into a variation of this problem where after following steps here, I still got the 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")

whereis npm did not show /usr/bin. Running sudo apt-get install npm did the trick.

@Aristophanes888

This comment has been minimized.

Aristophanes888 commented Nov 9, 2018

This command worked for me, and I changed 6 to 8 to get the latest:

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

Also, I had to run bash again after this. I didn't need to update my profile.

This worked for me thanks!

@pavedwave

This comment has been minimized.

pavedwave commented Nov 12, 2018

I'm running into the same issue, but the solutions above haven't worked yet. Windows 10, just installed the Ubuntu 18 LTS from Microsoft Store, and trying to get nodejs to work with it:

"which npm" results in -bash: /mnt/c/Program Files/nodejs/npm, so I tried:
alias "npm"="/mnt/c/Program Files/nodejs/npm" -- thinking the quotes will handle that space, but when I try doing npm -v, or any npm command, I get:
-bash: /mnt/c/Program: No such file or directory (breaks on the space)

And I've tried installing multiple versions like this: curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
but it always results in a long list of failures, a few examples below (trimmed down for readability):

Populating apt-get cache...

  • apt-get update
    Ign:1 http://security.ubuntu.com/ubuntu bionic-security InRelease
    ...
    Ign:11 http://archive.ubuntu.com/ubuntu bionic/multiverse Translation-en
    Reading package lists... Done
    W: Problem unlinking the file /var/lib/apt/lists/partial/.apt-acquire-privs-test.FtvgMR - IsAccessibleBySandboxUser (13: Permission denied)
    ...
    W: Problem unlinking the file /var/lib/apt/lists/partial/.apt-acquire-privs-test.2qYoiP - IsAccessibleBySandboxUser (13: Permission denied)
    ...
    E: The repository 'http://archive.ubuntu.com/ubuntu bionic-updates Release' no longer has a Release file.
    ...
    W: Problem unlinking the file /var/cache/apt/srcpkgcache.bin - RemoveCaches (13: Permission denied)
    Error executing command, exiting
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment