[英]How do I make a working symlink to a command in my node_modules .bin folder on Windows?
I'd like to run lab
from my root directory without having to mess with %bindir%
or .\\node_modules\\.bin\\lab.cmd
. 我想从我的根目录运行
lab
,而不必弄乱%bindir%
或.\\node_modules\\.bin\\lab.cmd
。 I want to be able to run tests with $ lab
and that's it. 我希望能够使用
$ lab
进行测试,仅此而已。
Here's my attempt. 这是我的尝试。 Keep in mind that I've already set up some aliases for things like
grep
in Powershell. 请记住,我已经为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...
Naming the alias lab.cmd didn't do anything. 给别名lab.cmd命名没有任何作用。 Is this possible on Windows?
在Windows上可以吗?
I really think it's a matter of Windows not really being built like that. 我真的认为这不是Windows真正建立的问题。 I do think there is probably a way you could sort out the symlink but in all reality this is what the various powershell profiles are there for.
我确实认为您可以通过某种方式整理出符号链接,但实际上,这就是各种powershell配置文件的用途。 When something shouldn't be system wide but you want easy and quick access to it.
当某些事情不应该在系统范围内出现,但是您希望轻松快速地访问它时。
If you want it to be available just to yourself you can put it in $profile, if you want it to be available to any user you happen to run powershell as you can put it in C:\\windows\\System32\\WindowsPowerShell\\v1.0\\Microsoft.PowerShell_profile.ps1 如果您只希望自己使用它,则可以将其放在$ profile中,如果您希望将它提供给任何用户,则可以运行powershell,因为可以将其放在C:\\ windows \\ System32 \\ WindowsPowerShell \\ v1中。 0 \\ Microsoft.PowerShell_profile.ps1
The functionality for symlinks exists in Windows, but it isn't as fleshed out as in *nix, for better or for worse, depending on locations, filenames and a whole host of other quirky things you are likely to run into all manner of problems. Windows中存在符号链接的功能,但它并不如* nix那样充实,无论好坏,这取决于位置,文件名以及可能会遇到各种问题的许多其他古怪的事物。 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.