Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when using ES6 import #63

Open
QyInvoLing opened this issue May 11, 2023 · 0 comments
Open

Error when using ES6 import #63

QyInvoLing opened this issue May 11, 2023 · 0 comments

Comments

@QyInvoLing
Copy link

  • version:1.2.1
  • node version:20.1.0
  • npm (or yarn) version:pnpm 7.28

Do you want to request a feature or report a bug?:
I came across a bug.
What is the current behavior?:
I copied the example code and found that Icannot initialize the PixivApp instance. However, when I switched my current ES6 import method (import PixivAppApi from 'pixiv-app-api' ) to CommonJS module(const PixivAppApi =require('pixiv-app-api' )), it works.

The console log is:

 this.pixiv = new PixivAppApi(this.config.username as string, this.config.password as string, {
                     ^
TypeError: pixiv_app_api_1.default is not a constructor
    at new Pixiv (D:\work\michanDaily\src\services\puller\Pixiv\main.ts:30:22)
    at Object.<anonymous> (D:\work\michanDaily\src\app.ts:14:9)
    at Module._compile (node:internal/modules/cjs/loader:1267:14)
    at Module.m._compile (D:\work\michanDaily\node_modules\.pnpm\[email protected]_pilkwpwcmsgv4hfi6z42mdzm2m\node_modules\ts-node\src\index.ts:1618:23)
    at Module._extensions..js (node:internal/modules/cjs/loader:1321:10)
    at Object.require.extensions.<computed> [as .ts] (D:\work\michanDaily\node_modules\.pnpm\[email protected]_pilkwpwcmsgv4hfi6z42mdzm2m\node_modules\ts-node\src\index.ts:1621:12)
    at Module.load (node:internal/modules/cjs/loader:1125:32)
    at Function.Module._load (node:internal/modules/cjs/loader:965:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:83:12)
    at phase4 (D:\work\michanDaily\node_modules\.pnpm\[email protected]_pilkwpwcmsgv4hfi6z42mdzm2m\node_modules\ts-node\src\bin.ts:649:14)

What is the expected behavior?:
Using ES6 import works.
Suggested solution:
I've checked the source code and found no obvious error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant