As you can see below,
%AppData%\npm is added in the system Path variable. I've also tried adding it to the User Path variable. The file
grunt.cmd exists in the directory, but only works if I specify it with an absolute path. AKA, path does not work.
C:\Users\TeamCity>echo %path% %AppData%\npm;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows \System32\WindowsPowerShell\v1.0\;c:\Program Files (x86)\Microsoft SQL Server\10 0\Tools\Binn\;c:\Program Files\Microsoft SQL Server\100\Tools\Binn\;c:\Program F iles\Microsoft SQL Server\100\DTS\Binn\;c:\Program Files (x86)\Microsoft SQL Ser ver\100\Tools\Binn\VSShell\Common7\IDE\;c:\Program Files (x86)\Microsoft SQL Ser ver\100\DTS\Binn\;C:\Program Files\Microsoft\Web Platform Installer\;C:\Program Files\nodejs\ C:\Users\TeamCity>dir %appdata%\npm Volume in drive C has no label. Volume Serial Number is B845-1135 Directory of C:\Users\TeamCity\AppData\Roaming\npm 05/29/2013 03:14 AM <DIR> . 05/29/2013 03:14 AM <DIR> .. 05/29/2013 03:14 AM 298 grunt 05/29/2013 03:14 AM 159 grunt.cmd 05/29/2013 03:13 AM <DIR> node_modules 2 File(s) 457 bytes 3 Dir(s) 23,690,498,048 bytes free C:\Users\TeamCity>grunt 'grunt' is not recognized as an internal or external command, operable program or batch file. C:\Users\TeamCity>%appdata%\npm\grunt grunt-cli: The grunt command line interface. (v0.1.9)
- Windows Server 2008 R2 Datacenter
- Service Pack 1
I don't think you can defer variable expansion in the path. What's in the path is used as is, it doesn't get re-interpreted during a search.
In fact, you must have worked really hard to get that in as
%AppData% since you would need to do something like:
If you were to just use:
you'd find the actual path would be substituted, so that the path becomes: