Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"FullPath cannot be applied" error for nested node_modules in VS2015 CTP6

I'm playing around with MVC6 + Aurelia project in Visual Studio 2015 CTP6, and came across something interesting.

My node_modules is by default in the project root and everything works fine. However, I'd like to keep source tree a bit more organized and moved node_modules, jspm_modules and related stuff to a subfolder - eg. MyApp\client\node_modules etc.

But now Visual Studio stops loading the project. Here's exception from "VsProjectFault.failure.txt":

(Inner Exception #1) System.InvalidOperationException: The item metadata "%(FullPath)" cannot be applied to the path "client\node_modules\conventional-changelog\node_modules\lodash.assign\node_modules\lodash._basecreatecallback\node_modules\lodash.bind\node_modules\lodash._createwrapper\node_modules\lodash._basecreatewrapper\node_modules\". C:\Work\xxxxxxxxxx\xxxxxxxxxx.xxx\src\client\node_modules\conventional-changelog\node_modules\lodash.assign\node_modules\lodash._basecreatecallback\node_modules\lodash.bind\node_modules\lodash._createwrapper\node_modules\lodash._basecreatewrapper\node_modules\
   at Microsoft.Build.Shared.ErrorUtilities.ThrowInvalidOperation(String resourceName, Object[] args)
   at Microsoft.Build.Shared.ErrorUtilities.VerifyThrowInvalidOperation(Boolean condition, String resourceName, Object arg0, Object arg1, Object arg2)
   at Microsoft.Build.Shared.FileUtilities.ItemSpecModifiers.GetItemSpecModifier(String currentDirectory, String itemSpec, String definingProjectEscaped, String modifier, String& fullPath)
   ...
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.VisualStudio.ProjectSystem.Utilities.DataflowExtensions.<>c__DisplayClass37`2.<<CreateSelfFilteringTransformBlock>b__38>d__0.MoveNext()

Apparently the problem is in node_modules recursive path being too long - and there's bug #6960 in Node tracker

Node needs an alternative approach to endless, recursively nested node_modules folders on Windows. Most Windows tools, utilities and shells cannot handle file and folder paths longer than 260 characters at most.

...which seems like closed as won't fix to me:

Node isn't going to change, so this isn't really a Node issue. The problem is not with the module loading semantics, but with the module installation semantics. (The two are related, but not identical.)

But then I don't understand how come the project was loading in the first place, because some paths are definitely over 260 symbols even if node_modules is under the project root!

Is there some setting in config or something which helps Visual Studio 2015 to load the project with node_modules, what's going on?

like image 959
andreister Avatar asked Mar 31 '15 13:03

andreister


2 Answers

http://bstruthers.com/weblog/2013/02/06/Cannot_evaluate_the_item_metadata_FullPath/

This is because the character limitation in file path in VS has crossed. Copy the folder inside a root folder and try.

like image 79
ramputan Avatar answered Nov 08 '22 23:11

ramputan


I managed to fix this issue in a Windows 10 development machine by enabling the Win32 long paths policy using the Group Policy Editor. Here are the required steps (depending if you've the Anniversary Update installed or not):

Before Anniversary Update

If you’re running a Windows 10 build between 14352 and RTM 1607, aka “Anniversary Update“, you need to do the following:

  • Launch the Group Policy Editor by pressing Windows Key and manually typing gpedit.msc, then hit the Enter key.
  • Navigate to Local Computer Policy > Computer Configuration > Administrative Templates > System > Filesystem > NTFS
  • Locate the Enable NTFS long paths option and enable it with a click.

As an alternative, you can also achieve the same results by executing the following registry commands:

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\FileSystem]
"LongPathsEnabled"=dword:00000001

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem]
"LongPathsEnabled"=dword:00000001

After Anniversary Update

If you’re running a post-Anniversary Update Windows 10 build (RTM 1067 or newer), you need to use the following:

  • Launch the Group Policy Editor by pressing Windows Key and manually typing gpedit.msc, then hit the Enter key.
  • Navigate to Local Computer Policy > Computer Configuration > Administrative Templates > System > Filesystem
  • Locate the Enable Win32 long paths option and enable it with a click.

In case you need additional details you can also check out this blog post I wrote on the topic.

like image 33
Darkseal Avatar answered Nov 08 '22 23:11

Darkseal