0

• I recently implemented server side rendering using Angular Universal in my application.

• This required converting my node server file from .js to .ts.

• Typescript is compiled to javascript using webpack

• Everything works when I run the server using : ts-node server.ts

• After compiling to javascript using webpack, I get the following error for Firebase API's used in my server:

ERROR in ./node_modules/google-auto-auth/node_modules/mime/index.js Module not found: Error: Can't resolve './types/standard' in '/Users/XX/Desktop/XX/XX/node_modules/google-auto-auth/node_modules/mime'

ERROR in ./node_modules/@google-cloud/storage/node_modules/mime/index.js Module not found: Error: Can't resolve './types/standard' in '/Users/XX/Desktop/XX/OM-XX/node_modules/@google-cloud/storage/node_modules/mime'

etc. etc.

How can this be tackled?

My webpack config code:

const path = require('path');
const webpack = require('webpack');

module.exports = {
  entry: {server: './server.ts'},
  resolve: {extensions: ['.js', '.ts']},
  target: 'node',
  mode: 'none',
  // this makes sure we include node_modules and other 3rd party libraries
  externals: [/(node_modules|main\..*\.js)/],
  output: {
    path: __dirname,
    filename: '[name].js'
  },
  module: {
    rules: [
      {test: /\.ts$/, loader: 'ts-loader'}
    ]
  },
  plugins: [
    // Temporary Fix for issue: https://github.com/angular/angular/issues/11580
    // for "WARNING Critical dependency: the request of a dependency is an expression"
    new webpack.ContextReplacementPlugin(
      /(.+)?angular(\\|\/)core(.+)?/,
      path.join(__dirname, 'src'), // location of your src
      {} // a map of your routes
    ),
    new webpack.ContextReplacementPlugin(
      /(.+)?express(\\|\/)(.+)?/,
      path.join(__dirname, 'src'),
      {}
    )
  ]
}

Thank you!

1
  • i am also trying same thing. did you got any solution @Mazlan Alam Malik??? Please help me out Commented Jul 5, 2018 at 12:03

1 Answer 1

0

Maybe this can be related to missing types?

Try to install missing typesfor all the packages that throw error

e.g: npm install --save @types/google-cloud__storage

Sign up to request clarification or add additional context in comments.

1 Comment

I just tried your suggestion and still didn’t work. Thank you for the suggestion.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.