rangle / angular-ssr

Angular 4+ server-side rendering solution compatible with @angular/material, jQuery, and other libraries that touch the DOM (as well as providing a rich feature set!)
BSD 2-Clause "Simplified" License
279 stars 38 forks source link

Cannot find module '@angular/platform-browser' #57

Closed galtalmor closed 5 years ago

galtalmor commented 7 years ago

I'm trying to run the simple setup of ng-render for the first time on a pretty simple Angular 4 app I have. For some reason I get the error Unhandled Promise rejection: Cannot find module '@angular/platform-browser'. I couldn't find anything related here or on Google, so any help would be appreciated.

Obviously I am using the platform-browser in my AppModule in the standard way: import { BrowserModule } from '@angular/platform-browser'; Any reason this shouldn't work?

The output I get is this:

[info] Rendering application from source (working path: C:\Users\Me\AppData\Local\Temp\61dd0e8dc6993) 
Unhandled Promise rejection: Cannot find module '@angular/platform-browser' ; Zone: <root> ; Task: Promise.then ; Value: { Error: Cannot find module '@angular/platform-browser'
    at Function.Module._resolveFilename (module.js:470:15)
    at Function.Module._load (module.js:418:25)
    at Module.require (module.js:498:17)
    at require (internal/module.js:20:19)
    at Object.2 (C:\Users\Me\AppData\Local\Temp\61dd0e8dc6993\webpack:\external "@angular\platform-browser":1:1)
    at e (C:\Users\Me\AppData\Local\Temp\61dd0e8dc6993\webpack:\webpack\bootstrap 89d9a0feecaa42a70d63:19:1)
    at Object.Cos1 (C:\Users\Me\AppData\Local\Temp\61dd0e8dc6993\webpack:\0.js:6456:84)
    at e (C:\Users\Me\AppData\Local\Temp\61dd0e8dc6993\webpack:\webpack\bootstrap 89d9a0feecaa42a70d63:19:1)
    at Object.39 (C:\Users\Me\AppData\Local\Temp\61dd0e8dc6993\webpack:\0.js:3456:18)
    at e (C:\Users\Me\AppData\Local\Temp\61dd0e8dc6993\webpack:\webpack\bootstrap 89d9a0feecaa42a70d63:19:1)
    at C:\Users\Me\AppData\Local\Temp\61dd0e8dc6993\webpack:\webpack\bootstrap 89d9a0feecaa42a70d63:65:1
    at Object.<anonymous> (C:\Users\Me\AppData\Local\Temp\61dd0e8dc6993\webpack:\webpack\bootstrap 89d9a0feecaa42a70d63:65:1)
    at Module._compile (module.js:571:32)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:488:32)
    at tryModuleLoad (module.js:447:12)
  code: 'MODULE_NOT_FOUND',
  __zone_symbol__currentTask:
   ZoneTask {
     _zone:
      Zone {
        _properties: {},
        _parent: null,
        _name: '<root>',
        _zoneDelegate: [Object] },
     runCount: 0,
     _zoneDelegates: null,
     _state: 'notScheduled',
     type: 'microTask',
     source: 'Promise.then',
     data: undefined,
     scheduleFn: undefined,
     cancelFn: null,
     callback: [Function],
     invoke: [Function] } } Error: Cannot find module '@angular/platform-browser'
    at Function.Module._resolveFilename (module.js:470:15)
    at Function.Module._load (module.js:418:25)
    at Module.require (module.js:498:17)
    at require (internal/module.js:20:19)
    at Object.2 (C:\Users\Me\AppData\Local\Temp\61dd0e8dc6993\webpack:\external "@angular\platform-browser":1:1)
    at e (C:\Users\Me\AppData\Local\Temp\61dd0e8dc6993\webpack:\webpack\bootstrap 89d9a0feecaa42a70d63:19:1)
    at Object.Cos1 (C:\Users\Me\AppData\Local\Temp\61dd0e8dc6993\webpack:\0.js:6456:84)
    at e (C:\Users\Me\AppData\Local\Temp\61dd0e8dc6993\webpack:\webpack\bootstrap 89d9a0feecaa42a70d63:19:1)
    at Object.39 (C:\Users\Me\AppData\Local\Temp\61dd0e8dc6993\webpack:\0.js:3456:18)
    at e (C:\Users\Me\AppData\Local\Temp\61dd0e8dc6993\webpack:\webpack\bootstrap 89d9a0feecaa42a70d63:19:1)
    at C:\Users\Me\AppData\Local\Temp\61dd0e8dc6993\webpack:\webpack\bootstrap 89d9a0feecaa42a70d63:65:1
    at Object.<anonymous> (C:\Users\Me\AppData\Local\Temp\61dd0e8dc6993\webpack:\webpack\bootstrap 89d9a0feecaa42a70d63:65:1)
    at Module._compile (module.js:571:32)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:488:32)
    at tryModuleLoad (module.js:447:12)
wnabil commented 7 years ago

Oh i think this is not related to angular-ssr You need to run npm install --save @angular/platform-browser

galtalmor commented 7 years ago

@wnabil I have the package installed and it works in normal usage with angular build and serve. I only get this error when running angular-ssr. But just to re-validate, I tried to reinstall it and run angular-ssr again, like you suggested, and got the same result.

wnabil commented 7 years ago

Well i am using the angular ssr express and everything is working fine i suggest you to copy that example from the examples folder and copy your code inside it. this is what i did and everything is working fine without any problem.

galtalmor commented 7 years ago

@wnabil Okay, will try that. Thanks for the suggestion.

e-schultz commented 7 years ago

are you still having an issue with this?

galtalmor commented 7 years ago

@e-schultz Yep. Couldn't get neither ng-render nor ssr express working. With ng-render the problem stayed the same. I couldn't figure out what's the issue with platform-browser. It is installed and working perfectly on standard client, but not with ng-render. I'm using latest version of all Angular modules and Angular Material.

clbond commented 7 years ago

@galtalmor Neither of the example repos work for you? I just fetched the latest and was able to build and run both of them. Are you sure that module is installed? Can you do ls node_modules/@angular/platform-browser?

manoharreddyporeddy commented 5 years ago

For existing project:

npm install
npm run build

For new project:

npm install -g @angular/cli
ng new yourprojectname1
galtalmor commented 5 years ago

Well, this is a year old issue. Probably not relevant anymore, so I'm going to close it.