2018-04-08

dotnet new install issue - Error: Value cannot be null

dotnet, template, core, cli

banner

Photo by Matt Lamers on Unsplash

.NET CLI has made it easy to create a new template. Sometimes you might get a following error message while creating a SPA template.

https://gist.github.com/dance2die/8b718a44aa893504105337808287b21d

I will show you what has caused it and how to get around it.

🤔 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.

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 on dev.to site 😉.