paginate-info
paginate-info copied to clipboard
Node.js Could not find a declaration file for paginate-info
Greetings,
I'm using node.js v10.16.2 and am unable to use your module per the errors seen when I try to require this module...
const paginateInfo = require('paginate-info');
In this require I receive the '...' that expresses "Could not find a declaration file for module 'paginate-info'". This then will not allow me to do any imports as suggested...
import {calculateLimitAndOffset, paginate} from 'paginate-info';
and node throws an error.
Can you please share what I might be doing wrong or provide a fix on your end?
Thanks,
The ...
warning is from typescript warning from you IDE, I guess you use VSCODE. Vscode support for Javascript is based on typescript, but the code should still run regardless.
For import
statements you'll need to use a transpiler like babeljs to make it work. But the code below should work alright with out import statement.
const { calculateLimitAndOffset, paginate } = require('paginate-info')
const { limit, offset } = calculateLimitAndOffset(2, 20)
// limit = 20, offset = 20
Reach out if this doesn't work
Thanks for the quick turn around, if you don't hear from me, it worked :)
You are correct, I'm using VSCode, unfortunately the server is still throwing an error at this...
const { calculateLimitAndOffset, paginate } = require('paginate-info')
SyntaxError: Invalid or unexpected token
I don't have the TypeScript module installed, is that the issue?
You can try this.
const pagination = require('paginate-info');
// use pagination.calculateLimitAndOffset or pagination.paginate
Thanks Mcdavid, as shared in my initial thread, I am doing what you suggest...
const paginateInfo = require('paginate-info');
however, it does not work. I've tried all of your suggestions above, but they are not working with node.