AdonisJS Error: class BaseCommand extends ace.Command - node.js

I cloned my repo from github and npm install on both folders.
Now, I am trying to run adonis server and I am getting this error.
It works on my other machine at home but when I'm on my laptop it is not working. Is it my fault?
adonis serve --dev
class BaseCommand extends ace.Command {
TypeError: Class extends value undefined is not a constructor or null
at Object.<anonymous> (/home/muse/.nvm/versions/node/v16.15.0/lib/node_modules/#adonisjs/cli/src/Commands/Base/index.js:17:31)
at Module._compile (node:internal/modules/cjs/loader:1105:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Module.require (node:internal/modules/cjs/loader:1005:19)
at require (node:internal/modules/cjs/helpers:102:18)
at Object.<anonymous> (/home/muse/.nvm/versions/node/v16.15.0/lib/node_modules/#adonisjs/cli/src/Commands/New/index.js:13:21)
at Module._compile (node:internal/modules/cjs/loader:1105:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
NPM audit
>edge.js <5.3.2
Severity: moderate
Cross-site Scripting in edge.js - https://github.com/advisories/GHSA-55r9-7mf8-m382
No fix available
node_modules/edge.js
#adonisjs/framework *
Depends on vulnerable versions of edge.js
node_modules/#adonisjs/framework
>2 moderate severity vulnerabilities
>Some issues need review, and may require choosing
a different dependency.
Package.json
{
"name": "adonis-api-app",
"version": "4.1.0",
"adonis-version": "4.1.0",
"description": "Adonisjs boilerplate for API server with pre-configured JWT",
"main": "index.js",
"scripts": {
"start": "node server.js",
"test": "node ace test"
},
"keywords": [
"adonisjs",
"adonis-app"
],
"author": "",
"license": "UNLICENSED",
"private": true,
"dependencies": {
"#adonisjs/ace": "^11.3.1",
"#adonisjs/auth": "^3.0.7",
"#adonisjs/bodyparser": "~2.0.9",
"#adonisjs/cors": "^1.0.7",
"#adonisjs/fold": "^4.0.9",
"#adonisjs/framework": "^5.0.9",
"#adonisjs/ignitor": "^2.0.8",
"#adonisjs/lucid": "^6.1.3",
"sqlite3": "^5.0.11"
},
"autoload": {
"App": "./app"
}
}

Related

Error: Cannot find module 'node-events' | Discord.js

I am running a Discord bot using Discord.js on Repl.it, and just recently upgraded my Discord.js to the latest 13.6.0 version, and ever since have gotten this error my console as soon as I try to run my application.
Error: Cannot find module 'node-events' | Discord.js
Require stack:
- /home/runner/myBot/node_modules/discord.js/src/client/BaseClient.js
- /home/runner/myBot/node_modules/discord.js/src/index.js
- /home/runner/myBot/node_modules/discord.js-commando/src/client.js
- /home/runner/myBot/node_modules/discord.js-commando/src/index.js
- /home/runner/myBot/index.js
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:815:15)
at Function.Module._load (internal/modules/cjs/loader.js:667:27)
at Module.require (internal/modules/cjs/loader.js:887:19)
at require (internal/modules/cjs/helpers.js:74:18)
at Object.<anonymous> (/home/runner/myBot/node_modules/discord.js/src/client/BaseClient.js:3:22)
at Module._compile (internal/modules/cjs/loader.js:999:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
at Module.load (internal/modules/cjs/loader.js:863:32)
at Function.Module._load (internal/modules/cjs/loader.js:708:14)
Now, I have updated my Node.js version to 16.6.1, like was suggested by basically every post I could find about this error, but that still didn't quite seem to fix it. Running the node -v command in my Repl.it shell returns 16.6.1, as it should, and so I don't really know what I'm missing at this point.
I will put my package.json down below too, if it can help.
If anyone knows how I could fix this issue, I would gladly appreciate it.
Thank you in advance!
{
"name": "myBot",
"version": "1.0.0",
"main": "index.js",
"scripts": {
"start": "node ."
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"#replit/database": "^2.0.1",
"base": "^3.0.0",
"canvas": "^2.9.0",
"common-tags": "^1.8.0",
"discord": "^0.8.2",
"discord.js": "^13.6.0",
"discord.js-commando": "^0.12.3",
"dotenv": "^10.0.0",
"events": "^3.3.0",
"express": "^4.17.1",
"init": "^0.1.2",
"node-events": "0.0.2",
"node-fetch": "^2.6.1",
"snekfetch": "^4.0.4",
"twitch": "^4.6.0"
},
"devDependencies": {
"node": "^16.6.1"
},
"description": ""
}

How to develop multiple get router functions under same controller and same route in expressjs/nodejs?

I am using Express with Node and I have a requirement in which my client end application can request the similar URLs as
http://localhost:3008/api/mitems/7
http://localhost:3008/api/mitems/0/0/20
http://localhost:3008/api/mitems/7/2/0/20
these requests will return a JSON response.
I have configured express to route as follows:
router.get("/getbyId/:mid", mControllers.getById);
router.get("/:mid/:pNo/:pSize", mControllers.getM);
router.get("/:mid/:mItemId/:pNo/:pSize", mControllers.getMItems);
But this does not work properly. I am unsure of how to pass multiple parameters, that is, I am unsure if this is the correct way to do this. Is it?
Node considers first router.get("/getbyId/:mid", mControllers.getById); api with each different request whether I call from http://localhost:3008/api/mitems/0/0/20 or http://localhost:3008/api/mitems/7/2/0/20 but in both ways.
How should I overload the same API functions in nodejs or is there any better way to achieve this?
================================package.json===========================
{
"name": "A Demos",
"version": "1.0.0",
"description": "a Demo",
"main": "index.js",
"dependencies": {
"body-parser": "^1.19.0",
"cors": "^2.8.5",
"express": "^4.17.1",
"express-validator": "^6.12.0",
"handlebars": "^4.7.7",
"mysql": "^2.18.1",
"nodemailer": "^6.6.1",
"nodemon": "^2.0.12"
},
"devDependencies": {},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "test",
"license": "ISC"
}
The error , I am getting a nodejs side
Error: Route.get() requires a callback function but got a [object Undefined]
at Route.<computed> [as get] (s\node_modules\express\lib\router\route.js:202:15)
at Function.proto.<computed> [as get] (s\node_modules\express\lib\router\index.js:510:19)
at Object.<anonymous> (s\routes\menus-routes.js:12:8)
at Module._compile (internal/modules/cjs/loader.js:1085:14)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
at Module.load (internal/modules/cjs/loader.js:950:32)
at Function.Module._load (internal/modules/cjs/loader.js:790:14)
at Module.require (internal/modules/cjs/loader.js:974:19)
at require (internal/modules/cjs/helpers.js:92:18)
at Object.<anonymous> (s\index.js:16:21)
Express considers routes in the order you add them to the router, so /:mid/:pNo/:pSize is considered before /:mid/:mItemId/:pNo/:pSize. Since the request /mitems/0/0/20 matches the not only the latter, but also the former (with :mid = 'mitems', :pNo = '0', :pSize = '0'), it will be handled by mControllers.getM.
Therefore, add the longer (more specific) route before the shorter (less specific) one, e.g.,
router.get("/getbyId/:mid", mControllers.getById);
router.get("/:mid/:mItemId/:pNo/:pSize", mControllers.getMItems);
router.get("/:mid/:pNo/:pSize", mControllers.getM);
The getbyId route comes first, because the word getbyId is more specific than the placeholder :mid.

Cannot find module 'fs-extra' npm

using truffle#5.3.2, ganache#2.5.4, node#10.19.0, npm#7.10.0
for blockchain developers
$ sudo truffle migrate --reset
works fine...consume gas from fake account in ganache.
$ sudo truffle test
Using network 'development'.
Error: Cannot find module 'fs-extra'
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 (internal/modules/cjs/helpers.js:25:18)
at Object.call (/usr/local/lib/node_modules/truffle/node_modules/#truffle/debugger/dist/external "fs-extra":1:18)
at r (/usr/local/lib/node_modules/truffle/node_modules/#truffle/debugger/dist/webpack/bootstrap:19:22)
at Object.call (/home/amal/work/truffle/packages/compile-common/dist/src/profiler/updated.js:33:26)
at r (/usr/local/lib/node_modules/truffle/node_modules/#truffle/debugger/dist/webpack/bootstrap:19:22)
at Object.call (/home/amal/work/truffle/packages/compile-common/dist/src/profiler/profiler.js:20:19)
at r (/usr/local/lib/node_modules/truffle/node_modules/#truffle/debugger/dist/webpack/bootstrap:19:22)
at Object.call (/home/amal/work/truffle/packages/compile-common/dist/src/profiler/index.js:3:18)
at r (/usr/local/lib/node_modules/truffle/node_modules/#truffle/debugger/dist/webpack/bootstrap:19:22)
at Object.call (/home/amal/work/truffle/packages/compile-common/dist/src/index.js:25:18)
at r (/usr/local/lib/node_modules/truffle/node_modules/#truffle/debugger/dist/webpack/bootstrap:19:22)
at Object.call (/home/amal/work/truffle/packages/debugger/lib/session/index.js:31:1)
at r (/usr/local/lib/node_modules/truffle/node_modules/#truffle/debugger/dist/webpack/bootstrap:19:22)
at Object.call (/home/amal/work/truffle/packages/debugger/lib/debugger.js:4:1)
at r (/usr/local/lib/node_modules/truffle/node_modules/#truffle/debugger/dist/webpack/bootstrap:19:22)
at Object.call (/home/amal/work/truffle/packages/debugger/debugger.js:1:16)
at __webpack_require__ (/usr/local/lib/node_modules/truffle/node_modules/#truffle/debugger/dist/webpack/bootstrap:19:22)
at /usr/local/lib/node_modules/truffle/node_modules/#truffle/debugger/dist/webpack/bootstrap:83:10
at factory (/usr/local/lib/node_modules/truffle/node_modules/#truffle/debugger/dist/debugger.js:1:1152)
at /usr/local/lib/node_modules/truffle/node_modules/#truffle/debugger/dist/webpack/universalModuleDefinition:3:20
at Object.<anonymous> (/usr/local/lib/node_modules/truffle/node_modules/#truffle/debugger/dist/webpack/universalModuleDefinition:1:1)
at Module._compile (internal/modules/cjs/loader.js:778: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)
Truffle v5.3.2 (core: 5.3.2)
Node v10.19.0
Measure Taken
1.
$ sudo npm ls fs-extra
pet-shop#1.0.0 /home/phenomenal/blockchain
+-- fs-extra#3.0.1
-- lite-server#2.6.1
-- browser-sync#2.26.14
`-- fs-extra#3.0.1 deduped
*npm install -g npm-reinstall*
*npm install -g npm#latest*
But nothing works!!!
Here's the test file election.js
var Election = artifacts.require('./Election.sol');
contract("Election",function(accounts){
it("Initializes with two candidates",function(){ //Mocha framework
return Election.deployed().then(function(instance){
return instance.candidatesCount();
}).then(function(count){
asserts equal(count,2); //Chai Library Function
});
});
});
Election.sol file
contract Election {
//Model of Candidate
struct Candidate{
uint id;
string name;
uint voteCount;
}
//Store Candidate
//Fetch Candidate
mapping(uint => Candidate) public listOfCandidates;
//Store Candidate Count
uint public candidatesCount;
//construtor
constructor() public {
addCandidate("Candidate 1");
addCandidate("Candidate 2");
}
function addCandidate(string memory _name) private{
candidatesCount++;
listOfCandidates[candidatesCount] = Candidate(candidatesCount,_name,0);
}
}
Package.json file
{
"name": "pet-shop",
"version": "1.0.0",
"description": "",
"main": "truffle.js",
"directories": {
"test": "test"
},
"scripts": {
"dev": "lite-server",
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"devDependencies": {
"lite-server": "^2.3.0"
},
"dependencies": {
"fs-extra": "^3.0.1"
}
}
Please help If require I would send you the complete project or required files.

react-native command gives syntaxerror

Currently using react-native-cli: 1.0.0 and react-native: 0.26.3
Running react-native command in terminal gives this error.
/Users/appleuser/Desktop/asklegit-app/node_modules/babel-core/lib/transformation/file/options/option-manager.js:229
throw err;
^
SyntaxError: /Users/appleuser/package.json: Error while parsing JSON - Unexpected end of input
at Object.parse (native)
at OptionManager.addConfig (/Users/appleuser/Desktop/asklegit-app/node_modules/babel-core/lib/transformation/file/options/option-manager.js:225:62)
at OptionManager.findConfigs (/Users/appleuser/Desktop/asklegit-app/node_modules/babel-core/lib/transformation/file/options/option-manager.js:442:30)
at OptionManager.init (/Users/appleuser/Desktop/asklegit-app/node_modules/babel-core/lib/transformation/file/options/option-manager.js:484:12)
at compile (/Users/appleuser/Desktop/asklegit-app/node_modules/babel-register/lib/node.js:112:69)
at loader (/Users/appleuser/Desktop/asklegit-app/node_modules/babel-register/lib/node.js:158:14)
at Object.require.extensions.(anonymous function) [as .js] (/Users/appleuser/Desktop/asklegit-app/node_modules/babel-register/lib/node.js:168:7)
at Module.load (module.js:357:32)
at Function.Module._load (module.js:314:12)
at Module.require (module.js:367:17)
Anyone got a clue? Couldn't find anything online :(
This is my package.json
{
"name": "asklegit",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start",
"ios": "react-native run-ios",
"android": "react-native run-android"
},
"dependencies": {
"react": "15.0.2",
"react-native": "0.26.3"
}
}
I don't know under which circumstances but it seems sometimes there is an empty package.json created in the users home directory. A completely empty file is by default not correct syntax so calling applications will produce an error.
Solution is to just delete the empty package.json.

Cannot find module 'browser-window' with nightmare and nodejs

I'm having hard time to run nightmare from nodejs. I started with the example provided in the README, tried different version of electron-prebuilt and different tweaks but I'm always getting node that can't find the browser-window module.
Here is my test :
> node --version
v5.3.0
>
> cat .\package.json
{
"name": "webautomation",
"version": "1.0.0",
"private": true,
"description": "testing nightmare.js",
"main": "main.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"dependencies": {
"nightmare": "^2.1.2",
"vo": "^1.0.3"
},
"author": "ECH",
"license": "ISC"
}
>
> npm install
>
> npm ls electron-prebuilt
webautomation#1.0.0 D:\MyEnv\WebAutomation
└─┬ nightmare#2.1.2
└── electron-prebuilt#0.35.4
>
> cat .\main.js
var Nightmare = require('nightmare');
console.log("require done");
dream = Nightmare();
dream.goto('http://yahoo.com');
dream.end();
>
> node main.js
creation done
module.js:338
throw err;
^
Error: Cannot find module 'browser-window'
at Function.Module._resolveFilename (module.js:336:15)
at Function.Module._load (module.js:286:25)
at Module.require (module.js:365:17)
at require (module.js:384:17)
at Object.<anonymous> (D:\MyEnv\WebAutomation\node_modules\nightmare\lib\runner.js:6:21)
at Module._compile (module.js:434:26)
at Object.Module._extensions..js (module.js:452:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Function.Module.runMain (module.js:475:10)
>
Can someone tell me what I'm missing here ?
I got a similar problem with my app and I think its because there was a change in the API or so. Anyway, what I did to fix it was this:
In the main.js file, I replaced the old line
var BrowserWindow = require('browser-window');
with this
var BrowserWindow = require('electron').BrowserWindow;
and then it worked.
You could refer to the thread here: https://github.com/Polymer/polymer-cli/issues/404

Resources