Skip to content
This repository was archived by the owner on Apr 8, 2020. It is now read-only.

Uncaught ReferenceError: vendor_ is not defined #717

Closed
IEvangelist opened this issue Feb 26, 2017 · 8 comments
Closed

Uncaught ReferenceError: vendor_ is not defined #717

IEvangelist opened this issue Feb 26, 2017 · 8 comments

Comments

@IEvangelist
Copy link
Member

IEvangelist commented Feb 26, 2017

Issue

I'm not really sure why this is no longer working. It was originally entirely functional as I expected it to be. Today I went to run the application and then this started happening.

image

  • Angular2 Template
  • Microsoft Visual Studio Enterprise 2017 RC
    Version 15.0.26206.0 D15REL
    Microsoft .NET Framework
    Version 4.6.01586
  • node v6.9.5
  • npm v3.10.10
  • angular 2 v2.4.7
λ dotnet --info
.NET Command Line Tools (1.0.0-rc4-004771)

Product Information:
 Version:            1.0.0-rc4-004771
 Commit SHA-1 hash:  4228198f0e

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.14393
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\1.0.0-rc4-004771

Last week while running the same code base, this all worked. Please let me know what else might be helpful in trying to fix this. Also, I did manually try executing the webpack --config webpack.config.vendor.js command to no avail.

Steps to Reproduce

dotnet new angular
dotnet restore
npm install
dotnet run

Open in Visual Studio, build and run. Open developer tools and look @ the console.

@IEvangelist
Copy link
Member Author

IEvangelist commented Feb 28, 2017 via email

@kirstenOtting
Copy link

kirstenOtting commented Feb 28, 2017

I ran into an issue with the same symptoms today (same exact console errors), and it turned out to be because I was missing the Microsoft.AspNetCore.StaticFiles middleware. Once I added the nuget package and app.UseStaticFiles(); in my Startup.cs the problem went away. Not sure if you have the same root cause, but it might give you an idea.

@ttcg
Copy link

ttcg commented Mar 1, 2017

Please rebuild the project and refresh the browser. The error should go away.
Normally, I got that error whenever after I have compiled webpack vendor and webpack.

@schneidenbach
Copy link

I'm able to reproduce this, same version, same error, when using the yeoman template.

.NET Command Line Tools (1.0.0-rc4-004771)

Product Information:
 Version:            1.0.0-rc4-004771
 Commit SHA-1 hash:  4228198f0e

Runtime Environment:
 OS Name:     Mac OS X
 OS Version:  10.11
 OS Platform: Darwin
 RID:         osx.10.11-x64
 Base Path:   /usr/local/share/dotnet/sdk/1.0.0-rc4-004771

Steps to reproduce

npm install -g yo generator-aspnetcore-spa
yo aspnetcore-spa (select React-Redux)
dotnet run

@ttcg
Copy link

ttcg commented Mar 2, 2017

Have you added 'aspnet-prerendering' in webpack.config.vendor.js?

I am using @angular 2.4.8 and webpack 2.2.1 and I got the similar error as yours.

capture

@IEvangelist
Copy link
Member Author

@ttcg I didn't add anything to the webpack.config.vendor.js -- I assumed it was accurate. @schneidenbach Yeah, I'm not sure... one thing I ended up doing was tweaking the .UseStaticFiles, I am using the overload to configure its options. With that said, I realized that if you do this you should also invoke the not overload prior to that - it seemed to have solved the issue.

app.UseStaticFiles()
   .UseStaticFiles(options => /* omitted for brevity */);

@SteveSandersonMS
Copy link
Member

For anyone else reading, make sure you've regenerated your vendor and other files via the command line as follows:

webpack --config webpack.config.vendor.js
webpack

(if needed, run npm install -g webpack first to install the Webpack CLI tool)

@IEvangelist I know you said you did run the webpack --config webpack.config.vendor.js. In that case, I don't know how it's not working for you. It certainly does when I try it. Did you also run webpack afterwards and restart your application? I followed your repro steps, and had no such problem, nor would I expect to, since the dotnet new and Yeoman templates put the necessary vendor JS file on disk as part of project creation. Is it possible you're doing something else besides those steps? Your repro steps don't say anything about changing UseStaticFiles so I'm not sure why that's involved in this discussion. @schneidenbach I tried you repro steps too and again it worked fine.

If you have more info that will reproduce this issue on a clean machine, please let us know. Otherwise I'm not sure how we can take any action on it.

@IEvangelist
Copy link
Member Author

@SteveSandersonMS as always, thank you for your time sir! It is much appreciated. I can no longer reproduce this issue either, and my original source (without change) seems to be working. I'm writing this off as being related to webpack. Thanks again!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants