Elastic node apm not adding hooks for express

Hi,
I am using express 4.16.2 version.
To use node APM , we added following line at the start of code in index.js server file.
Code : import apm from 'elastic-apm-node/start';
When we run, node APM not sending any data to apm -server.
So we created custom error to check if APM is working and we get these error, but didn't get transaction data.
We change logLevel to debug for APM and found that APM not adding hook for express.
Logs as follows :

pwa@0.1.0 build:start /home/PWA
node dist/server.bundle.dev.js

adding hook to Node.js module loader
shimming https@8.10.0 module
shimming https.Server.prototype.emit function
listening on 3000...

What Node.js version are you using? Are you using babel to support that import statement, or are you using the new es modules support built into Node.js?

Node version : v8.10.0
Yes , we are using new es modules support built into Node.js.
import apm from 'elastic-apm-node/start';

The es module support in Node.js is still experimental in 12.x. As such, the implementation could break compatibility at any time. I would recommend using babel to transpile it to require, for the time being.

We are also using with babel-loader for the same through webpack but problem still exists.

webpack server config

var webpack = require('webpack');
//var path = require('path');
//const nodeExternals = require('webpack-node-externals');

const getClientEnvironment = require('./env');
const paths = require('./paths');
const publicPath = paths.servedPath;
const publicUrl = publicPath.slice(0, -1);
const env = getClientEnvironment(publicUrl);
env.stringified = {...env.stringified,'isClientEnv':JSON.stringify(false)};
var LodashModuleReplacementPlugin = require('lodash-webpack-plugin');

const config = {
entry: {
server: paths.serverIndexJs,
},
output: {
filename: '[name].bundle.dev.js',
path: paths.serverBuildPath,
chunkFilename: '[name].[chunkhash].js'
},
mode : env.raw.NODE_ENV,
target : 'node',
// externals: [nodeExternals()],
resolve: {
modules: ['node_modules', 'src'],
extensions: ['*', '.js', '.json']
},
module: {
rules: [
// {
// test: [/.bmp$/, /.gif$/, /.jpe?g$/, /.png$/],
// loader: require.resolve('url-loader'),
// options: {
// limit: 10000,
// name: 'static/media/[name].[hash:8].[ext]',
// },
// },
{
test: /.(jsx|js)?$/,
exclude: /(node_modules/)/,
use: {
loader: "babel-loader"
}

        },
        {
            test: /\.css$/,
            use: [
                {
                    loader: "css-loader/locals"
                }
            ]
        }
    ],

},
plugins: [
    new webpack.DefinePlugin(env.stringified),
    new LodashModuleReplacementPlugin
]

};
module.exports = config;

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.