DEV Community

loading...

“dotnet new install” issue – “Error: Value cannot be null”

dance2die profile image Sung M. Kim Originally published at slightedgecoder.com Updated on ・2 min read

.NET CLI has made it easy to create a new template.
But sometimes you might be frustrated the following not-so-helpful error message while creating a SPA template.

> dotnet new -i .\NewTemplate
Error: Could not install ".\NewTemplate".
Error: Value cannot be null.
Parameter name: key
Enter fullscreen mode Exit fullscreen mode

🤔 The Cause

According to Mike Lorbetske, the error occurs when one of the node_modules folders contain a template.json file.

TL;DR – the particular node modules that have been added to the project contain a template.json file

💡 Resolution

So if you have a node_modules folder in your template, delete it then you are good to go.

NOTE 📝: The next version of .NET CLI templating engine (dotnet new3) has --trace:authoring option but wouldn’t be helpful in this case according to Mike.

🚪 Closing Remark

I’ve reported the issue on GitHub and Mike is preparing a PR to address this issue.
The issue page has the comprehensive steps to reproduce the error and how to resolve it.

**** UPDATE 2018/04/10 ****
The fix will be available in "The CLI after 2.1.300-preview2".

This issue was found while creating a new SPA template for ASP.NET Core with React.js with ES6 because the default template uses TypeScript.

You can find more about how to use it in my previous article, ASP.NET Core 2 React.js Template with ES6 (not TypeScript) .😉.

Discussion (2)

Collapse
thejoezack profile image
Joe Zack

This is the kind of post I love to see when I have that kind of error :)

Collapse
dance2die profile image
Sung M. Kim Author

Thanks Joe.

I go back to this kind of post as a reference😊.
And hope others can save time, as well 👍.

Forem Open with the Forem app