rapid7 / r7insight_node

node logging support for InsightOps

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Cannot use the package

aheintz opened this issue · comments

When I install the package using yarn add r7insight_node and includes import Logger from "r7insight_node" I get the following error:

<project-dir>/node_modules/codependency/index.js:206
        var lastDir = baseModule.filename;
                                 ^

TypeError: Cannot read properties of undefined (reading 'filename')
    at Object.exports.findPackage (<project-dir>/node_modules/codependency/index.js:206:27)
    at Object.exports.register (<project-dir>/node_modules/codependency/index.js:323:24)
    at Object.<anonymous> (<project-dir>/node_modules/r7insight_node/src/index.js:13:34)
    at Module._compile (node:internal/modules/cjs/loader:1101:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at ModuleWrap.<anonymous> (node:internal/modules/esm/translators:190:29)
    at ModuleJob.run (node:internal/modules/esm/module_job:185:25)
    at async Promise.all (index 0)

hey @aheintz!

  • what node/yarn version are you using?
  • can you try import * as Logger from 'r7insight_node';?

The codependency package that we pull in does not seem to work if you are using modules (i.e. "type": "module" in package.json). For now the simple answer would appear to be to not use modules (if you want to use import syntax, you'll need to transpile). I'll create a ticket for this in our internal bug tracker.

Yeah it looks like codependency attempts to enforce CommonJS syntax. The features it provides are provided out of the box by NPM (and yarn) these days, so I've replaced it with those in my PR, and verified that both ES6 import syntax and CommonJS import syntax will work going forward

Hi @aheintz, this should now be fixed in version 3.2.1. Can you confirm?

closing as no response, @aheintz if the issue hasn't been solved, feel free to re-open!