question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

TypeError: Cannot read property 'slice' of undefined

See original GitHub issue
TypeError: Cannot read property 'slice' of undefined
    at Function.detectModule (/app/dist/webpack:/node_modules/@pm2/io/build/main/utils/module.js:30:1)
    at RuntimeStatsService.init (/app/dist/webpack:/node_modules/@pm2/io/build/main/services/runtimeStats.js:17:1)
    at PMX.init (/app/dist/webpack:/node_modules/@pm2/io/build/main/pmx.js:82:1)
    at new Pmx (/app/dist/webpack:/Modules/Pmx/index.ts:11:26)
    at Object../index.ts (/app/dist/webpack:/index.ts:33:13)
    at __webpack_require__ (/app/dist/webpack:/webpack/bootstrap:19:1)
    at /app/dist/webpack:/webpack/bootstrap:83:1
    at Object.<anonymous> (/app/dist/app.js:87:10)
    at Module._compile (internal/modules/cjs/loader.js:776:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:787:10)

packege.json

{
  "name": "example",
  "version": "1.0.0",
  "description": "",
  "scripts": {
    "start": "yarn build && yarn app",
    "build": "webpack --mode development",
    "build-ci": "webpack  --verbose --no-color --mode development",
    "app": "nodemon ./dist/app.js",
    "test": "mocha -r ts-node/register test/index.test.ts"
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "@pm2/io": "^4.2.5",
    "@sentry/node": "5.5.0",
    "axios": "^0.18.1",
    "http-graceful-shutdown": "^2.2.3",
    "koa": "^2.7.0",
    "koa-bodyparser": "^4.2.1",
    "koa-requestid": "^2.0.1",
    "koa-router": "^7.4.0",
    "minter-js-sdk": "^0.17.1",
    "redis": "^2.8.0",
    "retry-axios": "^1.0.1",
    "stacktrace-parser": "^0.1.6",
    "telegram-api": "^4.2.0",
    "toml": "^3.0.0",
    "winston": "^3.2.1"
  },
  "devDependencies": {
    "@types/async": "^2.0.49",
    "@types/bluebird": "^3.5.24",
    "@types/chai": "^4.0.10",
    "@types/mocha": "^2.2.45",
    "@types/redis": "^2.8.7",
    "@types/underscore": "^1.8.8",
    "awesome-typescript-loader": "^3.1.2",
    "chai": "^3.5.0",
    "clean-webpack-plugin": "^0.1.17",
    "dts": "^0.1.1",
    "istanbul-instrumenter-loader": "^2.0.0",
    "mocha": "^6.2.0",
    "node-loader": "^0.6.0",
    "phantomjs-prebuilt": "^2.1.14",
    "source-map-loader": "^0.2.4",
    "standard": "^12.0.1",
    "ts-loader": "^4.2.0",
    "ts-node": "^8.1.0",
    "tsconfig-paths": "^3.3.1",
    "tsconfig-paths-webpack-plugin": "^3.0.4",
    "tslint": "^5.8.0",
    "typedoc": "^0.15.0",
    "typescript": "^2.6.2",
    "webpack": "^4.1.0",
    "webpack-cli": "^3.1.2",
    "webpack-node-externals": "^1.6.0"
  }
}

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:8 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
Eywekcommented, Aug 12, 2019

Done, we were experiencing troubles with the CI.

0reactions
wirwolfcommented, Aug 13, 2019

@ahmedkotb

const path = require('path');
const CleanWebpackPlugin = require('clean-webpack-plugin');
const TSConfigPathsPlugin = require('tsconfig-paths-webpack-plugin');
const context = path.resolve(__dirname, 'src');

module.exports = {
    context,
    mode: "development",
    entry: getEntryPoints(),
    output: {
        filename: '[name].js',
        path: path.resolve(__dirname , 'dist')
    },
    resolve: {
        extensions: ['.ts', '.js', '.node', '.json'],
        modules: ['node_modules', path.resolve(__dirname, 'src')],
        alias: {
            hiredis: path.resolve(__dirname, 'alias', 'hiredis.js'),
        },
        plugins: [
            new TSConfigPathsPlugin({
                configFile: "./tsconfig.json",
                logLevel: "info",
                extensions: [".ts", ".tsx"]
            })
        ]
    },
    externals: ['node_modules'],
    module: {
        rules: [
            {
                test: /\.ts$/,
                loader: 'ts-loader',
                options: {
                    configFile: path.resolve(__dirname, 'tsconfig.json')
                },
                exclude: [/node_modules/, path.resolve('dist')]
            },
            {
                test: /\.node$/,
                loader: 'node-loader'
            },
        ]
    },
    target: 'node',
    devtool: "source-map",
//    plugins: [
//        new CleanWebpackPlugin(path.resolve(__dirname, 'dist')),
//    ],
    stats: {
        colors: true,
        warnings: false
    }
};

function getEntryPoints() {
//    const fs = require('fs');
//    let modules = fs.readdirSync(path.resolve(context, 'modules'));
    let result = {
         App: './App.ts',
    };

//    modules.forEach((module) => result[module] = `./modules/${module}/index.ts`);

    return result;
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

Problem with error Cannot read property 'slice' of undefined
I faced the same error today, and solved it by initializing the array to an empty array before performing any slice ...
Read more >
TypeError: Cannot read property 'slice' of undefined - Support
Hello, I encountered the same problem with the new version solc compiler. Error:
Read more >
Cannot read property 'slice' of undefined error when trying to ...
Hi guys, As the title says, I am getting a Cannot read property 'slice' of undefined error in the console when trying to...
Read more >
TypeError: Cannot read property 'slice' of undefined - MongoDB
So you can not retrieve that token because there is no Header so there is undefined variable. You are trying to slice that...
Read more >
Cannot read property 'slice' of undefined version in new project
js): TypeError: Cannot read property 'slice' of undefined at throwVersionError (node_modules/@babel/helper-plugin-utils/lib/index.js:62:15) at ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found