FrozenPandaz / ng-universal-demo

171 stars 54 forks source link

Adding mongoose #14

Open nourissam opened 7 years ago

nourissam commented 7 years ago

i try to add mongoose to the project but i can't succed .i have this error when i try to sstart server; driver = !(function webpackMissingModule() { var e = new Error("Cannot find module \".\""); e.code = 'MODULE_NOT_FOUND'; throw e; }());

if you can help me

BillyQin commented 7 years ago

i have some question when i try to add jsdom to the project..

Koslun commented 7 years ago

@nourissam @BillyQin you need to have a more complete example to get any meaningful help. So that we can correct your example rather than write the solution for you. Likely better with more details than less.

Like all other opensource github libraries the issue section is not a good place to ask for help. Rather instead ask your question with more complete examples at stackoverflow: https://stackoverflow.com/questions/tagged/angular.

Tag them with angular and maybe more related tags like mongoose or jsdom respectively.

sylc commented 7 years ago

I had also some issues with mongoose. I fixed it by excluding mongoose from the server bundle. In webpack.serv.js add "externals" property as below:

module.exports = { entry: root('./src/main.server.ts'), output: { filename: 'server.js' }, target: 'node', externals: [ function(context, request, callback) { if (/mongoose/.test(request)) { return callback(null, 'commonjs ' + request); } if (/colors/.test(request)) { return callback(null, 'commonjs ' + request); } callback(); } ] };