Aurelia捆绑在Visual Studio 2015社区中

时间:2021-09-22 03:04:04

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会对脚本的实际捆绑产生什么影响,因为它会在自动运行时跳过某些模块?

1 个解决方案

#1


2  

Visual Studio 2015 uses very old version of Node and npm. I had the similar issue with Tools for Apache Cordova apps.

Visual Studio 2015使用非常旧版本的Node和npm。我在使用Tools for 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在内的某些文件来使用相同的节点和npm作为cmd。

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. Replacing with 4.2.2 one solves.

此外,它似乎vs不适用于最新的5.0.0节点。用4.2.2替换一个解决方案。

#1


2  

Visual Studio 2015 uses very old version of Node and npm. I had the similar issue with Tools for Apache Cordova apps.

Visual Studio 2015使用非常旧版本的Node和npm。我在使用Tools for 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在内的某些文件来使用相同的节点和npm作为cmd。

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. Replacing with 4.2.2 one solves.

此外,它似乎vs不适用于最新的5.0.0节点。用4.2.2替换一个解决方案。