简体   繁体   English

Visual Studio 2015社区中的Aurelia捆绑包

[英]Aurelia bundle in Visual Studio 2015 Community

I have a postinstall rule set in package.json as follows: 我在package.json设置了一个postinstall规则,如下所示:

"postinstall": "aurelia bundle --force"

If I run npm install from the cmd in the project folder, no error are displayed but when the project loads in Visual Studio 2015 Community, it show the following error in the Output window (but outputs the bundled file): 如果我从项目文件夹中的cmd运行npm install ,则不会显示任何错误,但是当项目在Visual Studio 2015社区中加载时,它会在“输出”窗口中显示以下错误(但输出捆绑的文件):

---> (Inner Exception #0) Microsoft.NodejsTools.Npm.PackageJsonException: Error reading package.json at '...\node_modules\aurelia-cli\node_modules\npm\node_modules\graceful-fs\package.json': Error reading package.json. The file may be parseable JSON but may contain objects with duplicate properties.

The following error occurred:

Can not add Newtonsoft.Json.Linq.JValue to Newtonsoft.Json.Linq.JObject. ---> Microsoft.NodejsTools.Npm.PackageJsonException: Error reading package.json. The file may be parseable JSON but may contain objects with duplicate properties.

The following error occurred:

Can not add Newtonsoft.Json.Linq.JValue to Newtonsoft.Json.Linq.JObject. ---> System.ArgumentException: Can not add Newtonsoft.Json.Linq.JValue to Newtonsoft.Json.Linq.JObject.
   at Newtonsoft.Json.Linq.JObject.ValidateToken(JToken o, JToken existing)
   at Newtonsoft.Json.Linq.JContainer.InsertItem(Int32 index, JToken item, Boolean skipParentCheck)
   at Newtonsoft.Json.Linq.JObject.InsertItem(Int32 index, JToken item, Boolean skipParentCheck)
   at Newtonsoft.Json.Linq.JContainer.AddInternal(Int32 index, Object content, Boolean skipParentCheck)
   at Newtonsoft.Json.Linq.JContainer.Add(Object content)
   at Newtonsoft.Json.Linq.JTokenWriter.AddValue(JValue value, JsonToken token)
   at Newtonsoft.Json.Linq.JTokenWriter.WriteNull()
   at Newtonsoft.Json.JsonWriter.AutoCompleteClose(JsonContainerType type)
   at Newtonsoft.Json.JsonWriter.WriteEndObject()
   at Newtonsoft.Json.JsonWriter.WriteEnd(JsonContainerType type)
   at Newtonsoft.Json.JsonWriter.WriteEnd()
   at Newtonsoft.Json.JsonWriter.AutoCompleteAll()
   at Newtonsoft.Json.Linq.JTokenWriter.Close()
   at Newtonsoft.Json.JsonWriter.System.IDisposable.Dispose()
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateJObject(JsonReader reader)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
   at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent)
   at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType)
   at Newtonsoft.Json.JsonConvert.DeserializeObject(String value, Type type, JsonSerializerSettings settings)
   at Microsoft.NodejsTools.Npm.ReaderPackageJsonSource..ctor(TextReader reader)
   --- End of inner exception stack trace ---
   at Microsoft.NodejsTools.Npm.ReaderPackageJsonSource..ctor(TextReader reader)
   at Microsoft.NodejsTools.Npm.FilePackageJsonSource..ctor(String fullPathToFile)
   --- End of inner exception stack trace ---
   at Microsoft.NodejsTools.Npm.FilePackageJsonSource.WrapExceptionAndRethrow(String fullPathToFile, Exception ex)
   at Microsoft.NodejsTools.Npm.FilePackageJsonSource..ctor(String fullPathToFile)
   at Microsoft.NodejsTools.Npm.DirectoryPackageJsonSource..ctor(String fullDirectoryPath)
   at Microsoft.NodejsTools.Npm.SPI.RootPackage..ctor(String fullPathToRootDirectory, Boolean showMissingDevOptionalSubPackages)
   at Microsoft.NodejsTools.Npm.SPI.NodeModules..ctor(IRootPackage parent, Boolean showMissingDevOptionalSubPackages)
   at Microsoft.NodejsTools.Npm.SPI.RootPackage..ctor(String fullPathToRootDirectory, Boolean showMissingDevOptionalSubPackages)
   at Microsoft.NodejsTools.Npm.SPI.NodeModules..ctor(IRootPackage parent, Boolean showMissingDevOptionalSubPackages)
   at Microsoft.NodejsTools.Npm.SPI.RootPackage..ctor(String fullPathToRootDirectory, Boolean showMissingDevOptionalSubPackages)
   at Microsoft.NodejsTools.Npm.SPI.NodeModules..ctor(IRootPackage parent, Boolean showMissingDevOptionalSubPackages)
   at Microsoft.NodejsTools.Npm.SPI.RootPackage..ctor(String fullPathToRootDirectory, Boolean showMissingDevOptionalSubPackages)
   at Microsoft.NodejsTools.Npm.SPI.NpmController.<RefreshAsync>d__1.MoveNext()<---

So does running npm install automatically from visual studio have any impact on the actual bundling of the scripts in a sense that it skips some modules when running automatically? 那么从Visual Studio自动运行npm install是否对脚本的实际捆绑有任何影响,就意味着它在自动运行时会跳过某些模块吗?

Visual Studio 2015 uses very old version of Node and npm. Visual Studio 2015使用非常旧的Node和npm版本。 I had the similar issue with Tools for Apache Cordova apps. 我在适用于Apache Cordova应用程序的工具中遇到了类似的问题。

You can make vs use the same Node and npm as cmd by changing some files including node.exe under C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\Common7\\IDE\\Extensions\\Microsoft\\Web Tools\\External 您可以通过更改C:\\ Program Files(x86)\\ Microsoft Visual Studio 14.0 \\ Common7 \\ IDE \\ Extensions \\ Microsoft \\ Web Tools \\ External下的某些文件(包括node.exe)来使vs使用与cmd相同的Node和npm。

Look for this article http://jameschambers.com/2015/09/upgrading-npm-in-visual-studio-2015/ 寻找这篇文章http://jameschambers.com/2015/09/upgrading-npm-in-visual-studio-2015/

In addition it looks like vs does not work with the latest 5.0.0 Node. 此外,vs似乎不适用于最新的5.0.0节点。 Replacing with 4.2.2 one solves. 用4.2.2代替一个解决。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM