unlight / sublime-import-helper

A Sublime Text Plugin that helps you to import your modules.
MIT License
69 stars 7 forks source link

"undefined is not a function" #47

Closed katanacrimson closed 6 years ago

katanacrimson commented 6 years ago

As on tin - running into this error suddenly when trying to "Update Imports". Probably some code I wrote, however...running tsc, the typescript compiles fine.

Exec error: TypeError: undefined is not a function
    at esm.module.then.items (C:\Users\katana\AppData\Roaming\Sublime Text 3\Packages\ImportHelper\backend_run.js:47:24)
    at <anonymous>
error: Import Helper
TypeError: undefined is not a function
    at esm.module.then.items (C:\Users\katana\AppData\Roaming\Sublime Text 3\Packages\ImportHelper\backend_run.js:47:24)
    at <anonymous>

Considering there's no context outside of the package itself, not sure what's going wrong here. LMK if you need any additional info.

katanacrimson commented 6 years ago

...Looking at the file referenced, it looks like it's the Array.push()...which doesn't make a whole lot of sense. Possibly the result array is getting nulled out somehow?

unlight commented 6 years ago

It is very weird. It should not depend on code that you have written. Please, check you version of node. v6.0.0+ is required.

katanacrimson commented 6 years ago

nvm installed version of node, using 8.9.0 currently.

katanacrimson commented 6 years ago

Just noticed that currently, if I run Update Imports, it gives me that error twice (the exact code block above). Not sure what to make of that, but it may be significant.

unlight commented 6 years ago

https://github.com/unlight/sublime-import-helper/blob/master/backend/commands/get_modules.js#L25 This line throws error. I cant imagine how I can get result as non array here. I can add stupid check there like Array.isArray(result) but I would like to catch this bug.

Yes, it is running twice. First run for dependecies, second for devDependencies

katanacrimson commented 6 years ago

In that case - here's dependencies and devDependencies (since you mentioned it - maybe it's relevant?):

  "dependencies": {
    "@types/node": "^8.0.54",
    "base62.js": "^0.5.0",
    "bcrypt": "^1.0.3",
    "config": "^1.28.1",
    "debug": "^3.1.0",
    "fs-extra": "^4.0.2",
    "koa": "^2.4.1",
    "koa-body": "^2.5.0",
    "koa-favicon": "^2.0.0",
    "koa-helmet": "^3.3.0",
    "koa-router": "^7.3.0",
    "koa-session-minimal": "^3.0.4",
    "koa-static": "^4.0.2",
    "mysql": "^2.15.0",
    "mysql2": "^1.5.1",
    "reflect-metadata": "^0.1.10",
    "sequelize": "^4.26.0",
    "sharp": "^0.18.4",
    "swagger2": "^0.0.26",
    "swagger2-koa": "^0.0.38"
  },
  "devDependencies": {
    "@types/chai": "^4.0.7",
    "@types/config": "^0.0.33",
    "@types/debug": "^0.0.30",
    "@types/fs-extra": "^4.0.5",
    "@types/koa": "^2.0.42",
    "@types/koa-router": "^7.0.27",
    "@types/mocha": "^2.2.44",
    "chai": "^4.1.2",
    "mocha": "^4.0.1",
    "sequelize-typescript": "^0.6.1",
    "ts-node": "^3.3.0",
    "tslint": "^5.8.0",
    "tslint-config-standard": "^7.0.0",
    "typescript": "^2.5.3"
  }
unlight commented 6 years ago

Thanks, it is reproducable now. I will investigate it.

unlight commented 6 years ago

Fixed in v1.7.6