1

Closed

Exception details with call stack in progress output window when invalid package.json

description

When you try installing a package and you have an invalid package.json (try adding an extra '{' at the beginning), you'll see this output. We shouldn't display the exception details with the call stack.
npm ERR! Failed to parse json
npm ERR! Unexpected token 
npm ERR! File: c:\users\huvalo\documents\visual studio 2013\Projects\NodejsApp17\package.json
npm ERR! Failed to parse package.json data.
npm ERR! package.json must be actual JSON, not just JavaScript.
npm ERR! 
npm ERR! This is not a bug in npm.
npm ERR! Tell the package author to fix their package.json file. JSON.parse

npm ERR! System Windows_NT 6.2.9200
npm ERR! command "C:\\Program Files\\nodejs\\\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "mongodb" "--save"
npm ERR! cwd c:\users\huvalo\documents\visual studio 2013\Projects\NodejsApp17
npm ERR! node -v v0.10.20
npm ERR! npm -v 1.3.11
npm ERR! file c:\users\huvalo\documents\visual studio 2013\Projects\NodejsApp17\package.json
npm ERR! code EJSONPARSE

Unable to read package.json file at 'c:\users\huvalo\documents\visual studio 2013\Projects\NodejsApp17\package.json'. Please ensure the file is valid JSON.

Reading failed because the following error occurred:

Invalid property identifier character: . Path '', line 1, position 1.
  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.NpmController.Refresh()
  at Microsoft.NodejsTools.Npm.SPI.NpmCommander.<InstallPackageByVersionAsync>d__0.MoveNext()Caused by:
Invalid property identifier character: . Path '', line 1, position 1.
  at Newtonsoft.Json.JsonTextReader.ParseProperty()
  at Newtonsoft.Json.JsonTextReader.ParseObject()
  at Newtonsoft.Json.JsonTextReader.ReadInternal()
  at Newtonsoft.Json.JsonTextReader.Read()
  at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CheckedRead(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.FilePackageJsonSource..ctor(String fullPathToFile)
Closed Mar 14 at 12:34 AM by huguesv
Verified.

comments

BartRead wrote Nov 24, 2013 at 1:41 AM

Yep, definitely shouldn't be showing that in release builds. Let me check it out.

BartRead wrote Dec 16, 2013 at 3:45 PM

This should be fixed in release builds after commit b4a0d3c885f9. I actually fixed this and committed a couple of weeks back, but the fix didn't make it into the alpha.

Debug builds will continue to show the full stack trace info, because it comes in quite useful.