簡體   English   中英

如何在Windows的node_modules .bin文件夾中建立到命令的有效符號鏈接?

[英]How do I make a working symlink to a command in my node_modules .bin folder on Windows?

我想從我的根目錄運行lab ,而不必弄亂%bindir%.\\node_modules\\.bin\\lab.cmd 我希望能夠使用$ lab進行測試,僅此而已。

這是我的嘗試。 請記住,我已經為Powershell中的grep等設置了一些別名。

$ ll .\node_modules\.bin | grep lab
-a----         7/5/2017   2:57 PM            293 lab
-a----         7/5/2017   2:57 PM            170 lab.cmd

$ cmd /c mklink lab .\node_modules\.bin\lab\lab.cmd
symbolic link created for lab <<===>> .\node_modules\.bin\lab\lab.cmd

$ ll lab

Mode                LastWriteTime         Length Name
----                -------------         ------ ----
-a---l         7/7/2017   9:04 AM              0 lab

$ lab
lab : The term 'lab' is not recognized as the name of a cmdlet, function, script file... 

$ ./lab
Program 'lab' failed to run: No application is associated with the specified file...

給別名lab.cmd命名沒有任何作用。 在Windows上可以嗎?

我真的認為這不是Windows真正建立的問題。 我確實認為您可以通過某種方式整理出符號鏈接,但實際上,這就是各種powershell配置文件的用途。 當某些事情不應該在系統范圍內出現,但是您希望輕松快速地訪問它時。

如果您只希望自己使用它,則可以將其放在$ profile中,如果您希望將它提供給任何用戶,則可以運行powershell,因為可以將其放在C:\\ windows \\ System32 \\ WindowsPowerShell \\ v1中。 0 \\ Microsoft.PowerShell_profile.ps1

Windows中存在符號鏈接的功能,但它並不如* nix那樣充實,無論好壞,這取決於位置,文件名以及可能會遇到各種問題的許多其他古怪的事物。 。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM