New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"dotnet new" fails to install a new template with "node_modules" with "Error: Value cannot be null" message #8989

Closed
dance2die opened this Issue Apr 4, 2018 · 1 comment

Comments

Projects
None yet
2 participants
@dance2die
Copy link

dance2die commented Apr 4, 2018

Steps to reproduce

  1. Create a new dotnet new SPA project, react.
dance2die@LELOUCH c:\misc\sources\github
> dotnet new react -n ThisFails
The template "ASP.NET Core with React.js" was created successfully.

Processing post-creation actions...
...
Manual instructions: Run "npm install"
  1. Go to the newly created project.
dance2die@LELOUCH c:\misc\sources\github
> cd ThisFails
  1. Install NPM packages.
dance2die@LELOUCH c:\misc\sources\github\ThisFails
> npm install
npm WARN read-shrinkwrap This version of npm is compatible with lockfileVersion@1, but npm-shrinkwrap.json was generated for lockfileVersion@0. I'll try to do my best with it!
...
added 546 packages in 136.886s
  1. Add a new template folder, .template.config and a new configuration file, template.json.
  2. Copy the following configuration to template.json file.
{
  "$schema": "http://json.schemastore.org/template",
  "author": "Sung Kim",
  "classifications": ["Web"],
  "name": "BadTemplate",
  "identity": "BadTemplate",
  "shortName": "badtemplate",
  "tags": {
    "language": "C#",
    "type": "project"
  },
  "sourceName": "BadTemplate",
  "preferNameDirectory": true
}
  1. Go up one directory.
dance2die@LELOUCH c:\misc\sources\github\ThisFails
> cd ..
  1. Install the template, ThisFails.
dance2die@LELOUCH c:\misc\sources\github
> dotnet new -i .\ThisFails
Error: Could not install ".\ThisFails".
Error: Value cannot be null.
Parameter name: key
...
Examples:
    dotnet new mvc --auth Individual
    dotnet new mstest
    dotnet new --help

Expected behavior

Go to the ThisFails folder and delete node_modules folder.

dance2die@LELOUCH c:\misc\sources\github
> cd ThisFails
dance2die@LELOUCH c:\misc\sources\github\ThisFails
> rmdir /S /Q node_modules

Go up one directory

dance2die@LELOUCH c:\misc\sources\github\ThisFails
> cd ..

Installing works without an error.

dance2die@LELOUCH c:\misc\sources\github
> dotnet new -i .\ThisFails
Templates                                         Short Name       Language          Tags
--------------------------------------------------------------------------------------------------------
...
BadTemplate                                       badtemplate      [C#]              Web
...
Examples:
    dotnet new mvc --auth Individual
    dotnet new console
    dotnet new --help

Actual behavior

Fails with following error message.

dance2die@LELOUCH c:\misc\sources\github                                                                
> dotnet new -i .\ThisFails                                                                             
Error: Could not install ".\ThisFails".                                                                 
Error: Value cannot be null.                                                                            
Parameter name: key                                                                                     
Templates                                         Short Name       Language          Tags               
--------------------------------------------------------------------------------------------------------
Console Application                               console          [C#], F#, VB      Common/Console     
Class library                                     classlib         [C#], F#, VB      Common/Library     
Unit Test Project                                 mstest           [C#], F#, VB      Test/MSTest        
xUnit Test Project                                xunit            [C#], F#, VB      Test/xUnit         
BadTemplate                                       badtemplate      [C#]              Web                
ASP.NET Core Empty                                web              [C#], F#          Web/Empty          
ASP.NET Core Web App (Model-View-Controller)      mvc              [C#], F#          Web/MVC            
ASP.NET Core Web App                              razor            [C#]              Web/MVC/Razor Pages
ASP.NET Core with Angular                         angular          [C#]              Web/MVC/SPA        
ASP.NET Core with React.js                        react            [C#]              Web/MVC/SPA        
ASP.NET Core with React.js and Redux              reactredux       [C#]              Web/MVC/SPA        
ASP.NET Core Web API                              webapi           [C#], F#          Web/WebAPI         
global.json file                                  globaljson                         Config             
Nuget Config                                      nugetconfig                        Config             
Web Config                                        webconfig                          Config             
Solution File                                     sln                                Solution           
Razor Page                                        page                               Web/ASP.NET        
MVC ViewImports                                   viewimports                        Web/ASP.NET        
MVC ViewStart                                     viewstart                          Web/ASP.NET        
                                                                                                        
                                                                                                        
Examples:                                                                                               
    dotnet new mvc --auth Individual                                                                    
    dotnet new mstest                                                                                   
    dotnet new --help                                                                                   

Environment data

dance2die@LELOUCH c:\misc\sources\github\ThisFails   
> dotnet --info                                      
.NET Command Line Tools (2.0.2)                      
                                                     
Product Information:                                 
 Version:            2.0.2                           
 Commit SHA-1 hash:  a04b4bf512                      
                                                     
Runtime Environment:                                 
 OS Name:     Windows                                
 OS Version:  10.0.16299                             
 OS Platform: Windows                                
 RID:         win10-x64                              
 Base Path:   C:\Program Files\dotnet\sdk\2.0.2\     
                                                     
Microsoft .NET Core Shared Framework Host            
                                                     
  Version  : 2.0.0                                   
  Build    : e8b8861ac7faf042c87a5c2f9f2d04c98b69f28d
@livarcocc

This comment has been minimized.

Copy link
Member

livarcocc commented Apr 4, 2018

This issue was moved to dotnet/templating#1498

@livarcocc livarcocc closed this Apr 4, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment