Open kamalkech opened 7 years ago
Same issue
Use this repo (it has client & server rendering and is up to date): https://github.com/FrozenPandaz/ng-universal-demo @kamalkech @esakkikrishnan
@MarkPieszak i tryed to use this repo..it works.. but i'm trying to put mongoose but can t work at all.. and this repo is not able to open issues to discuss.. do you know how to make it compile with mongo? thanks!
Why wouldn't mongo work it's outside of Angular & SSR itself? What errors are you getting, must be setting up mongo wrong somewhere?
What i have is:
I'm trying to include this import * as mongoose from 'mongoose';
main.server.ts
it works.\server\user\routes.js
and I use the same import, it give me the error (the build works but the npm start gives me the error:IN build process:
WARNING in ./~/mongodb/~/es6-promise/dist/es6-promise.js
Module not found: Error: Can't resolve 'vertx' in '/Users/mariohmol/projetos/netgas/v2/web/node_modules/
mongodb/node_modules/es6-promise/dist'
@ ./~/mongodb/~/es6-promise/dist/es6-promise.js 131:20-30
In server process:
"stack": [
"Error: Cannot find module \".\"",
" at new Error (native)",
I think i found it.. is need to change the webpack.server.js
to have the webpack-node-externals
const { root } = require('./helpers');
const { AotPlugin } = require('@ngtools/webpack');
var nodeExternals = require('webpack-node-externals');
/**
* This is a server config which should be merged on top of common config
*/
module.exports = {
entry: root('./src/main.server.ts'),
output: {
filename: 'server.js'
},
target: 'node',
externals: [nodeExternals({
modulesFromFile: true
})]
};
npm install '@angular/animations' -- save
npm i -S @angular/animations
fixed it for me. It's an "unmet peer dependency" when running npm install
in this demo u can't found ngfactory