0

I recently created an api called jkanime using Typescript. I have the problem after publishing it on the npm platform, it shows me an error when using the API functions.

The error comes from the imports of some packages that I use to create the jkanime API.

Here I leave the api repository, if someone wants to help me how to correctly upload the package to the npm platform. https://github.com/ChrisMichaelPerezSantiago/jkanime


var jkanime = require("jkanime");

jkanime.lastAnimesAdded()
    .then(doc => console.log(doc));

Error

import * as cheerio from 'cheerio';
       ^

SyntaxError: Unexpected token *
    at Module._compile (internal/modules/cjs/loader.js:721:23)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:787:10)
    at Module.load (internal/modules/cjs/loader.js:653:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
    at Function.Module._load (internal/modules/cjs/loader.js:585:3)
    at Module.require (internal/modules/cjs/loader.js:690:17)
    at require (internal/modules/cjs/helpers.js:25:18)
    at Object.<anonymous> (C:\Users\c\Desktop\jkanime\test\index.js:1:13)
    at Module._compile (internal/modules/cjs/loader.js:776:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:787:10)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! test@1.0.0 start: `node index.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the test@1.0.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.       

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\c\AppData\Roaming\npm-cache\_logs\2019-08-16T01_07_55_949Z-debug.log

RunKit Link: https://npm.runkit.com/jkanime

Chris Michael
  • 1,557
  • 3
  • 15
  • 23

1 Answers1

0

You probably did not build your library before publishing also in package.json I see your main file is set to index.js and its nowhere to be seen?

I would advise you to use something like typescript-library-starter for creating typescript libraries at least check it to see what you need to create a library project with typescript.

Xesenix
  • 2,418
  • 15
  • 30
  • Hi @Xesenix, The main file is pointing to src / api / scraper / scraper.ts What happened was that I forgot to make the last commit to the repo .. But it still doesn't work for me. – Chris Michael Aug 16 '19 at 14:21
  • for publishing typescript libraries you need to have some build process involved that will create js version of your library and use that when imported to other projects – Xesenix Aug 16 '19 at 14:23
  • I will be using the template that you recommend me – Chris Michael Aug 16 '19 at 14:44