davideicardi / live-plugin-manager

Plugin manager and installer for Node.JS
MIT License
225 stars 43 forks source link

Fixed error with url-join import #8

Closed ArjunAtlast closed 5 years ago

ArjunAtlast commented 5 years ago

The error Module 'url-join' resolves to a non-module entity and cannot be imported using this construct is caused due to the import statement import * as urlJoin from 'url-join'. The supported syntax is import urlJoin = require('url-join')

davideicardi commented 5 years ago

Thanks for the PR! Can you just explain better the problem. In the past I didn't have any issue ... maybe it is related to an update of the url-join module?

ArjunAtlast commented 5 years ago

The module url-join exports a function. When we use import * as urlJoin from 'url-join' the export is expected to be an object hence throws an error. The supported format for such import is through es6 require i.e., import urlJoin = require('url-join')

Regards Arjun

On Mon 15 Apr, 2019, 4:19 PM Davide Icardi, notifications@github.com wrote:

Thanks for the PR! Can you just explain better the problem. In the past I didn't have any issue ... maybe it is related to an update of the url-join module?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/davideicardi/live-plugin-manager/pull/8#issuecomment-483202992, or mute the thread https://github.com/notifications/unsubscribe-auth/AM-KWheVxAoUkQYydr0-1WdK1jp1mvjfks5vhFkwgaJpZM4ct9kf .

davideicardi commented 5 years ago

I suspect that this is a check performed by the new typescript compiler. I think it is related to default export. But not sure about it ...

Maybe it is better to write:

import urlJoin from "url-join";

What do you think?

nsainaney commented 5 years ago

The would work but I believe you'll require allowSyntheticDefaultImports to be true in your tsconfig.json

davideicardi commented 5 years ago

I'm not an expert on all tsconfig settings, but given a fresh tsconfig (tsconfig --init) it seems to work. But in anyway I think that it should be a way to import any module without using require. I'm right?

davide

davideicardi commented 5 years ago

I have investigated a little bit. You are right, we should use import urljoin = require("url-join"). Here the official doc explain this: https://www.typescriptlang.org/docs/handbook/modules.html#export--and-import--require

I will fix this in the next release. Thanks for the suggestions.

davideicardi commented 5 years ago

Fixed in version 0.13 (I have updated all dependencies and fixed the errors). Thanks!

ArjunAtlast commented 5 years ago

Thanks, I'll check it out.

On Sat 20 Apr, 2019, 3:09 AM Davide Icardi, notifications@github.com wrote:

Fixed in version 0.13 (I have updated all dependencies and fixed the errors). Thanks!

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/davideicardi/live-plugin-manager/pull/8#issuecomment-485020656, or mute the thread https://github.com/notifications/unsubscribe-auth/ADHYUWU7RFNC76C56W6N6DLPRI3XHANCNFSM4HFX3EPQ .