dijs / wiki

Wikipedia Interface for Node.js
MIT License
313 stars 62 forks source link

Need help: wiki() is not a function #173

Closed Mondscheinritter closed 1 year ago

Mondscheinritter commented 1 year ago

I have tried the following example, but I always get only this error message. Does anyone have an idea what this could be. Thanks a lot

import wiki from 'wikijs';

wiki() .page('Batman') .then(page => page.info('alterEgo')) .then(console.log); // Bruce Wayne

λ node . file:///C:/Users/xxx/dev/git/xxx/index.js:36 wiki() ^

TypeError: wiki is not a function at file:///C:/Users/xxx/dev/git/xxx/index.js:36:1 at ModuleJob.run (node:internal/modules/esm/module_job:193:25) at async Promise.all (index 0) at async ESMLoader.import (node:internal/modules/esm/loader:530:24) at async loadESM (node:internal/process/esm_loader:91:5) at async handleMainPromise (node:internal/modules/run_main:65:12)

Node.js v18.12.1

marcoriosp commented 1 year ago

Same problem here:


import wiki from 'wikijs';

wiki()
        .page('Batman')
        .then(page => page.info('alterEgo'))
        .then(console.log); // Bruce Wayne

{ code: 'unknown', status: 'error', message: 'wiki is not a function', error: '' } TypeError: wiki is not a function at Task (file:///Users/marcorios/Projects/test-code/src/services/task.js:19:15) at Layer.handle [as handle_request] (/Users/marcorios/Projects/test-code/node_modules/express/lib/router/layer.js:95:5) at next (/Users/marcorios/Projects/test-code/node_modules/express/lib/router/route.js:144:13) at Route.dispatch (/Users/marcorios/Projects/test-code/node_modules/express/lib/router/route.js:114:3) at Layer.handle [as handle_request] (/Users/marcorios/Projects/test-code/node_modules/express/lib/router/layer.js:95:5) at /Users/marcorios/Projects/test-code/node_modules/express/lib/router/index.js:284:15 at param (/Users/marcorios/Projects/test-code/node_modules/express/lib/router/index.js:365:14) at param (/Users/marcorios/Projects/test-code/node_modules/express/lib/router/index.js:376:14) at Function.process_params (/Users/marcorios/Projects/test-code/node_modules/express/lib/router/index.js:421:3) at next (/Users/marcorios/Projects/test-code/node_modules/express/lib/router/index.js:280:10)

richardvanderdys commented 1 year ago

Strange. This must be an environment issue. How is the code being ran? Is it being compiled first into ES5?

The only time I ever see this error is when running this code:

const wiki = require('wiki')

wiki()

When I use import, I never see this issue.

dijs commented 1 year ago

Never mind, I found the issue and fixed it.

WikiJS did not support esm. Not it supports both esm and commonjs.

Please upgrade to v6.4.1

tgdn commented 5 months ago

@dijs is it possible that you broke TypeScript intellisense by making that change?

I'm on 6.4.1

image