2015-03-31 90 views
5

我在Visual Studio 2015 CTP6中使用MVC6 + Aurelia項目,並且遇到了一些有趣的事情。VS2015中的嵌套node_modules出現「FullPath can not be applied」錯誤CTP6

我的node_modules默認在項目根目錄下,一切正常。但是,我想保持源代碼樹更有組織,並將node_modules,jspm_modules和相關的東西移動到子文件夾 - 例如。 MyApp\client\node_modules

但現在Visual Studio停止加載項目。這裏的例外來自「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() 

顯然問題出在node_modules遞歸路徑過長 - 在節點跟蹤器有bug #6960

節點需要的替代方法層出不窮,在Windows上遞歸嵌套 node_modules文件夾。大多數Windows工具,實用程序和 shell最多不能處理超過260個字符的文件和文件夾路徑 。

...這似乎是closed as won't fix對我說:

節點是不會改變的,所以這是不是一個真正的節點問題。 問題不在於模塊加載語義,而在於模塊 安裝語義。 (這兩者是相關的,但不完全相同。)

但我不明白是怎麼來的項目被加載在首位,因爲一些路徑肯定超過260個符號,即使node_modules是該項目下根!

是否有一些設置在配置或東西,這有助於Visual Studio 2015加載項目與node_modules,發生了什麼?

+1

,這可能會進一步惡化。我會建議在github上提交一個問題,微軟團隊非常積極響應並且打開它來追蹤這些情況。對於它的價值,有一些人正在使用aurelia來處理NET5的流程,因爲wwwroot文件系統,所以也許你也應該在https://gitter.im/Aurelia/Discuss < - 非常棒的傢伙那裏看看。 – 2015-04-07 19:00:22

回答

1

我設法通過啓用Win32長路徑策略使用組策略編輯器在Windows 10開發機器中解決此問題。下面是必要的步驟(取決於如果你已經在週年更新安裝或沒有):

以前週年更新

如果你正在運行14352和RTM 1607之間的一個Windows 10的身材,又名「週年紀念更新」,你需要做到以下幾點:

  • 啓動的組策略編輯器Windows Key和手動鍵入gpedit.msc,然後點擊Enter鍵。
  • 導航到本地計算機策略>計算機配置>管理模板>系統>文件系統>NTFS
  • 找到啓用NTFS的長路徑選項,並點擊啓用。

作爲替代方案,還可以實現通過執行以下注冊表相同的結果命令:

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 

之後週年更新

如果你正在運行一個週年後更新Windows 10版本(RTM 1067或更新版本),您需要使用以下內容:

  • 通過按Windows Key並手動鍵入gpedit.msc,然後點擊Enter鍵,啓動組策略編輯器
  • 導航到本地計算機策略>計算機配置>管理模板>系統>文件系統
  • 找到Enable Win32 long paths選項,並點擊啓用它。

如果您需要關於該主題的更多細節,您還可以read this post

0

我發現它,你可以移動您的解決方案文件保存到您的項目所在的文件夾中。錯誤是由於Windows具有限制執行路徑中提供的字符數的路徑策略導致的。

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\ 

只需將您的項目文件(包括所有包的整體解決方案)到Work/XXXX文件夾,這樣就解決了它。

0

它看起來像你的項目超過MAX_PATH, 您可以嘗試到您的項目移動到一個較短的路徑(例如C:\ SRC) 有關詳細信息,請here

相關問題