You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Apr 8, 2020. It is now read-only.
Repository navigation
This repository was archived by the owner on Apr 8, 2020. It is now read-only.
Deploy to Azure Cannot find module 'angular2-universal-polyfills' #534
Not quite sure if this is an error related to the template or not, but I've created a test app with the aspnetcore-spa yo template with Angular 2 and tried deploying it to Azure App Services.
I get the following error:
Exception: Call to Node module failed with error: Prerendering failed because of error: Error: Cannot find module 'angular2-universal-polyfills'
at Function.Module._resolveFilename (module.js:469:15)
at Function.Module._load (module.js:417:25)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (D:\home\site\wwwroot\ClientApp\dist\main-server.js:87:19)
at __webpack_require__ (D:\home\site\wwwroot\ClientApp\dist\main-server.js:20:30)
at Object.<anonymous> (D:\home\site\wwwroot\ClientApp\dist\main-server.js:48:2)
at __webpack_require__ (D:\home\site\wwwroot\ClientApp\dist\main-server.js:20:30)
at D:\home\site\wwwroot\ClientApp\dist\main-server.js:40:18
at Object.<anonymous> (D:\home\site\wwwroot\ClientApp\dist\main-server.js:43:10)
Current directory is: D:\home\site\wwwroot
The code works fine in Visual Studio as well as locally and I'm not sure what I'm missing to make it work once published.
The reason I suggest this is that, if you don't specify a Node version, then it falls back on an old version with NPM 2.x, which doesn't correctly restore all Angular NPM packages. That would at least be consistent with the error message you're getting.
Can you provide repro steps based on deploying to a completely new Azure website? (Don't try re-deploying to your broken one, as you might now have a corrupted node_modules directory that continues to break further deployments)
I've been testing Azure deployment from several angles today, and didn't hit any issue like this. Since we don't have any information on how to reproduce it, I'm going to put it down to something unique to your scenario (e.g., a network failure during NPM restoration) and close this.
If you are able to describe how to reproduce the issue, please reopen with details!
@SteveSanderson Thanks for testing, I'm sorry I didn't have time these weeks to do further testing. I checked quickly that the node version as you suggested was indeed correctly set in the application settings in Azure, so I don't think that might be the issue I was facing.
I've deleted everything on Azure and will try again from scratch, writing down everything I'm doing and will reopen an issue with all the details if I face the issue again.
The main difference between what I did to publish and what you did in your blog post was that I'm using the dotnet publish command from a docker image (I'm using Atlassian Bitbucket Pipelines for CI/CD) and then copying everything in the publish repository to the publish FTP folder in Azure, so it's kind of reverse of what you do as far as I can tell.
Activity
SteveSandersonMS commentedon Jan 2, 2017
That's strange. The publishing certainly works as far as I'm aware.
Is it possible you forgot to specify a Node version when setting up your Azure website? See: http://blog.stevensanderson.com/2016/10/04/angular2-template-for-visual-studio/#now-lets-deploy
The reason I suggest this is that, if you don't specify a Node version, then it falls back on an old version with NPM 2.x, which doesn't correctly restore all Angular NPM packages. That would at least be consistent with the error message you're getting.
Can you provide repro steps based on deploying to a completely new Azure website? (Don't try re-deploying to your broken one, as you might now have a corrupted
node_modulesdirectory that continues to break further deployments)SteveSandersonMS commentedon Jan 7, 2017
I've been testing Azure deployment from several angles today, and didn't hit any issue like this. Since we don't have any information on how to reproduce it, I'm going to put it down to something unique to your scenario (e.g., a network failure during NPM restoration) and close this.
If you are able to describe how to reproduce the issue, please reopen with details!
Gimly commentedon Jan 9, 2017
@SteveSanderson Thanks for testing, I'm sorry I didn't have time these weeks to do further testing. I checked quickly that the node version as you suggested was indeed correctly set in the application settings in Azure, so I don't think that might be the issue I was facing.
I've deleted everything on Azure and will try again from scratch, writing down everything I'm doing and will reopen an issue with all the details if I face the issue again.
The main difference between what I did to publish and what you did in your blog post was that I'm using the
dotnet publishcommand from a docker image (I'm using Atlassian Bitbucket Pipelines for CI/CD) and then copying everything in the publish repository to the publish FTP folder in Azure, so it's kind of reverse of what you do as far as I can tell.