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
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.
Related
I clone the project from GitLab -> install node_modules by "npm install -g" -> and run "npm start" command in terminal but it give some errors as below.
Error Cannot find module '../services/'
Require stack:
- /opt/projects/api_server_node/node_modules/ravepay/lib/rave.bvn.js
- /opt/projects/api_server_node/node_modules/ravepay/index.js
- /opt/projects/api_server_node/services/flutterwaveService.js
- /opt/projects/api_server_node/controllers/flutterwaveController.js
- /opt/projects/api_server_node/controllers/bookingController.js
- /opt/projects/api_server_node/routes/booking.js
- /opt/projects/api_server_node/index.js
Error: Cannot find module '../services/'
Require stack:
- /opt/projects/api_server_node/node_modules/ravepay/lib/rave.bvn.js
- /opt/projects/api_server_node/node_modules/ravepay/index.js
- /opt/projects/api_server_node/services/flutterwaveService.js
- /opt/projects/api_server_node/controllers/flutterwaveController.js
- /opt/projects/api_server_node/controllers/bookingController.js
- /opt/projects/api_server_node/routes/booking.js
- /opt/projects/api_server_node/index.js
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:1029:15)
at Function.Module._load (internal/modules/cjs/loader.js:898:27)
at Module.require (internal/modules/cjs/loader.js:1089:19)
at require (internal/modules/cjs/helpers.js:73:18)
at Object.<anonymous>
(/opt/projects/api_server_node/node_modules/ravepay/lib/rave.bvn.js:2:22)
at Module._compile (internal/modules/cjs/loader.js:1200:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1220:10)
at Module.load (internal/modules/cjs/loader.js:1049:32)
at Function.Module._load (internal/modules/cjs/loader.js:937:14)
at Module.require (internal/modules/cjs/loader.js:1089:19)
at require (internal/modules/cjs/helpers.js:73:18)
at Object.<anonymous> (/opt/projects/api_server_node/node_modules/ravepay/index.js:17:11)
at Module._compile (internal/modules/cjs/loader.js:1200:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1220:10)
at Module.load (internal/modules/cjs/loader.js:1049:32)
at Function.Module._load (internal/modules/cjs/loader.js:937:14)
at Module.require (internal/modules/cjs/loader.js:1089:19)
at require (internal/modules/cjs/helpers.js:73:18)
at Object.<anonymous> (/opt/projects/api_server_node/services/flutterwaveService.js:16:17)
at Module._compile (internal/modules/cjs/loader.js:1200:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1220:10)
at Module.load (internal/modules/cjs/loader.js:1049:32)
at Function.Module._load (internal/modules/cjs/loader.js:937:14)
at Module.require (internal/modules/cjs/loader.js:1089:19)
at require (internal/modules/cjs/helpers.js:73:18)
at Object.<anonymous>
(/opt/projects/api_server_node/controllers/flutterwaveController.js:28:20)
at Module._compile (internal/modules/cjs/loader.js:1200:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1220:10)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! bookadabra_api#1.0.0 start: `node ./index.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the bookadabra_api#1.0.0 start script.
npm ERR! This is probably not a problem with npm. The`enter code here`re is likely
additional logging output above.```
screeshot of the error (https://prnt.sc/vpykry)
TL;DR: Downgrade the ravepay module from 1.3.0 to 1.2.4, but do take time to read the WARNING paragraph below first.
The stack trace indicates that your issue is in the ravepay module. Trying to use a plain installation of ravepay resulted in a similar error to what you're seeing for every version of Node.js I tried (15.x, 14.x, 12.x, and 10.x--all the versions currently supported by the Node.js project at the time of this writing).
There's no information about Node.js version support for ravepay, or at least not that I can find as of this writing. However, looking at their GitHub Action at the time of this writing reveals that they use Node.js 12.x. But using 12.x didn't help.
The current version of ravepay is 1.3.0. Downgrading to 1.2.4 fixes the issue.
$ node -v
v15.3.0
$ npm -v
7.0.14
$ npm install ravepay
npm WARN deprecated har-validator#5.1.5: this library is no longer supported
npm WARN deprecated request#2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
added 61 packages, and audited 61 packages in 3s
2 packages are looking for funding
run `npm fund` for details
2 high severity vulnerabilities
Some issues need review, and may require choosing
a different dependency.
Run `npm audit` for details.
$ npm ls ravepay
temp# /Users/trott/temp
└── ravepay#1.3.0
$ node -e "require('ravepay')"
node:internal/modules/cjs/loader:922
throw err;
^
Error: Cannot find module '../services/'
Require stack:
- /Users/trott/temp/node_modules/ravepay/lib/rave.bvn.js
- /Users/trott/temp/node_modules/ravepay/index.js
- /Users/trott/temp/[eval]
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:919:15)
at Function.Module._load (node:internal/modules/cjs/loader:763:27)
at Module.require (node:internal/modules/cjs/loader:991:19)
at require (node:internal/modules/cjs/helpers:92:18)
at Object.<anonymous> (/Users/trott/temp/node_modules/ravepay/lib/rave.bvn.js:2:22)
at Module._compile (node:internal/modules/cjs/loader:1102:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1131:10)
at Module.load (node:internal/modules/cjs/loader:967:32)
at Function.Module._load (node:internal/modules/cjs/loader:807:14)
at Module.require (node:internal/modules/cjs/loader:991:19) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'/Users/trott/temp/node_modules/ravepay/lib/rave.bvn.js',
'/Users/trott/temp/node_modules/ravepay/index.js',
'/Users/trott/temp/[eval]'
]
}
$ npm install ravepay#1.2.4
changed 1 package, and audited 61 packages in 1s
2 packages are looking for funding
run `npm fund` for details
2 high severity vulnerabilities
Some issues need review, and may require choosing
a different dependency.
Run `npm audit` for details.
$ npm ls
temp# /Users/trott/temp
└── ravepay#1.2.4
$ node -e "require('ravepay')"
$
WARNING: Even though that "fixes" the problem, those high severity audit warnings are not a reassuring sign on a credit card payment library. The ravepay module is relatively lightly used (227 weekly downloads at the time of this writing) and was last published a year ago (at the time of this writing). It is probably not much actively maintained and there is not evidence of a user base large enough to frequently surface simple issues like this and make solutions readily available to a user community. If you continue down this path, you may experience more problems like this. Be prepared.
EDIT: Oh yeah, and as #Andrei Ionita notes in their answer, don't install the project dependencies with the -g flag.
Try clearing your globally installed packages and installing the project without the -g flag.
I'm trying to set up a project using webpack. When I try to serve it using webpack I get this:
root#d690f9010746:~/chat-webapp# npm run serve
> chat-webapp#1.0.0 serve /root/chat-webapp
> webpack serve --config webpack.config.js
internal/modules/cjs/loader.js:638
throw err;
^
Error: Cannot find module '../../lib/webpack-cli'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
at Function.Module._load (internal/modules/cjs/loader.js:562:25)
at Module.require (internal/modules/cjs/loader.js:692:17)
at require (/root/chat-webapp/node_modules/v8-compile-cache/v8-compile-cache.js:161:20)
at Object.<anonymous> (/root/chat-webapp/node_modules/#webpack-cli/serve/index.js:4:20)
at Module._compile (/root/chat-webapp/node_modules/v8-compile-cache/v8-compile-cache.js:192:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:789: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)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! chat-webapp#1.0.0 serve: `webpack serve --config webpack.config.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the chat-webapp#1.0.0 serve 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! /root/.npm/_logs/2020-05-31T19_42_42_752Z-debug.log
The line /root/chat-webapp/node_modules/#webpack-cli/serve/index.js:4 (mentioned in the stacktrace) says: const WebpackCLI = require("../../lib/webpack-cli");. But I don't have the file /root/chat-webapp/node_modules/lib/webpack-cli - and even if I did, it's not in the #webpack-cli/serve repo, and the repo shouldn't be making assumptions about the locations of files it doesn't control.
And yet I can't find anyone or stackoverflow or anywhere else who's getting an error on the same relative path. So what am I missing? I've installed all the npm repos locally, which is a bit non-standard - could it be something to do with that?
I just found out about immutable.js.
I want to play around with it, get used to how it works.
Really simple. Don't even need to write code, just futzing with
it in the node shell interactively.
I have installed it:
$ npm install immutable
npm WARN saveError ENOENT: no such file or directory, open '/home/xxxxxxx/node/immutable/package.json'
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN enoent ENOENT: no such file or directory, open '/home/xxxxxxx/node/immutable/package.json'
npm WARN immutable No description
npm WARN immutable No repository field.
npm WARN immutable No README data
npm WARN immutable No license field.
+ immutable#3.8.2
added 1 package from 1 contributor and audited 1 package in 2.934s
found 0 vulnerabilities
...and then I attempt to work with it.
$ node
> const { Map } = require('immutable');
ReferenceError: Map is not defined
at Module._compile (internal/modules/cjs/loader.js:683:37)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
at Module.load (internal/modules/cjs/loader.js:599:32)
at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
at Function.Module._load (internal/modules/cjs/loader.js:530:3)
at Module.require (internal/modules/cjs/loader.js:637:17)
at require (internal/modules/cjs/helpers.js:20:18)
$ node -v
v10.10.0
$ npm -v
6.4.1
A little assistance in making sense of what I may have missed would be really cool.
TIA
UPDATE:
Just for the heck of it I tried this:
$ sudo npm install immutable
And now it works
???
While starting my application, I get this error. I have already checked and seen that the required module is well installed, and also gave it global access.
Hussains-MacBook-Pro:NodeRest-Shop Hussain$ npm start
> noderest-shop#1.0.0 start /Users/Hussain/Desktop/Development/Web/NodeRest-Shop
> nodemon server.js
module.js:549
throw err;
^
Error: Cannot find module 'binary-extensions'
at Function.Module._resolveFilename (module.js:547:15)
at Function.Module._load (module.js:474:25)
at Module.require (module.js:596:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (/Users/Hussain/Desktop/Development/Web/NodeRest-Shop/node_modules/is-binary-path/inde
x.js:3:24)
at Module._compile (module.js:652:30)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! noderest-shop#1.0.0 start: `nodemon server.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the noderest-shop#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! /Users/Hussain/.npm/_logs/2018-06-25T05_23_59_594Z-debug.log
You're missing the binary-extensions module, as seen in your log:
Error: Cannot find module 'binary-extensions'
It could be that you're missing some dependencies or forgot to include it.
You can install it using npm:
npm install binary-extensions
And include binaryExtensions in your project:
const binaryExtensions = require('binary-extensions');
I fixed this issue by running:
npm i npm#latest -g
Check your app.js file your index route should be
app.use(require('./routes/')); not app.use(require('./routes/index'));
I am trying to 'eb deploy' a node.js with javascript sdk addition.
It works fine locally but every time I have tried to - eb deploy- it I get this in the logs
npm ERR! npm bugs node-express
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!
npm ERR! npm owner ls node-express
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /var/app/current/npm-debug.log
> node-express#0.0.0 start /var/app/current
> node main.js
{ [Error: ENOENT: no such file or directory, open '.env'] errno: -2, code: 'ENOENT', syscall: 'open', path: '.env' }
module.js:327
throw err;
^
Error: Cannot find module 'parse/node'
at Function.Module._resolveFilename (module.js:325:15)
at Function.Module._load (module.js:276:25)
at Module.require (module.js:353:17)
at require (internal/module.js:12:17)
at Object.<anonymous> (/var/app/current/api/common/parse.js:3:13)
at Module._compile (module.js:409:26)
at Object.Module._extensions..js (module.js:416:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Module.require (module.js:353:17)
...npm ERR! code ELIFECYCLE
npm ERR! node-express#0.0.0 start: `node main.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the node-express#0.0.0 start script 'node main.js'.
npm ERR! This is most likely a problem with the node-express package,
I have repeatedly tried
npm install express --save
and yes I have also run npm install parse (it all works fine locally).
To no avail. Why would it all work like a charm locally but not on AWS EB ?
-Thanks for any clues.
Not sure if this will help someone. Ultimately I solved this by
'npm install moduleName --save' on all of my modules. One by one.
Still not sure why the site worked locally ?
-best of luck.