heroku host with eris - node.js

i want to host a discord bot using eris but every time i have a problem that tell me eris isn't install i have this error
Error: Cannot find module 'eris'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:581:15)
at Function.Module._load (internal/modules/cjs/loader.js:507:25)
at Module.require (internal/modules/cjs/loader.js:637:17)
at require (internal/modules/cjs/helpers.js:22:18)
at Object.<anonymous> (/app/bot.js:1:76)
at Module._compile (internal/modules/cjs/loader.js:689:30)
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)
and this the package.json file that i use i change to many files many times
{
"name": "manarceus",
"description": "project",
"version": "0.0.0",
"main": "bot.js",
"scripts": {
"start": "node bot.js"
},
"dependencies": {
"discord.js": "^11.3.2",
"discord.js-musicbot-addon": "^1.10.3",
"express": "^4.16.3",
"finalhandler": "^1.1.1",
"fortnite": "^3.0.0",
"fs": "^0.0.2",
"hastebin-gen":"1.3.1",
"canvas": "^1.6.11",
"giphy-api": "1.2.7",
"math-expression-evaluator":"1.2.17",
"common-tags":"1.7.2",
"zalgolize":"1.2.4",
"eris":"0.8.5",
"quick.db":"6.3.1",
"google-translate-api":"2.3.0",
"ascii-data-table":"2.1.1",
"array-sort": "1.0.0",
"table": "4.0.3",
"dateformat":"3.0.3",
"jimp":"0.2.28",
"get-youtube-id": "^1.0.0",
"moment": "^2.22.1",
"ms": "^2.1.1",
"goo.gl":"0.1.4",
"figlet":"1.2.0",
"google-it":"1.1.1",
"node-opus": "^0.2.7",
"opusscript": "0.0.6",
"python": "0.0.4",
"request": "^2.85.0",
"hypixel-api" : "1.0.0",
"router": "^1.3.2",
"snekfetch": "^3.6.4",
"sqlite": "^2.9.1",
"youtube-info": "^1.2.0",
"ytdl-core": "^0.20.2",
"ffmpeg": "0.0.4",
"pretty-ms": "3.1.0",
"ffmpeg-binaries": "^3.2.2-3",
"simple-youtube-api": "^5.0.2"
}
}
and i try to run commands to install eris too
any help

Related

Node JS Express removed files throws an error: 'Cannot find module './jobs.resolver''

So I tried to remove some files for code cleanup and some normalization. However express then gives me an error of: "Cannot find module './jobs.resolver'" Which is one of the files I removed.
Here is my package.json:
{
"name": "typegraphql-tutorial",
"version": "1.0.0",
"main": "dist/index",
"typings": "dist/index",
"author": "Tom Nagle",
"license": "MIT",
"scripts": {
"dev": "ts-node-dev --respawn --transpile-only --exit-child --watch src src/index.ts",
"start": "node ./src/index.ts"
},
"dependencies": {
"#typegoose/typegoose": "^9.7.1",
"apollo-server": "^3.5.0",
"bcrypt": "^5.0.1",
"bcryptjs": "^2.4.3",
"class-validator": "^0.13.2",
"config": "^3.3.6",
"cookie-parser": "^1.4.6",
"dotenv": "^10.0.0",
"express": "^4.17.3",
"graphql": "15.x",
"jsonwebtoken": "^8.5.1",
"mongoose": "^6.2.9",
"nanoid": "^3.1.30",
"reflect-metadata": "^0.1.13",
"type-graphql": "^1.1.1"
},
"devDependencies": {
"#types/bcrypt": "^5.0.0",
"#types/config": "^0.0.40",
"#types/cookie-parser": "^1.4.2",
"#types/jsonwebtoken": "^8.5.6",
"ts-node-dev": "^1.1.8",
"typescript": "^4.5.2"
}
}
Here is the error stack:
Error: Cannot find module './jobs.resolver'
Require stack:
- B:\jrevsols\jrevsolsBE\src\resolvers\index.ts
- B:\jrevsols\jrevsolsBE\src\index.ts
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
at Function.Module._load (node:internal/modules/cjs/loader:778:27)
at Module.require (node:internal/modules/cjs/loader:1005:19)
at require (node:internal/modules/cjs/helpers:102:18)
at Object.<anonymous> (B:\jrevsols\jrevsolsBE\src\resolvers\index.ts:4:1)
at Module._compile (node:internal/modules/cjs/loader:1101:14)
at Module._compile (B:\jrevsols\jrevsolsBE\node_modules\source-map-support\source-map-support.js:568:25)
at Module.m._compile (C:\Users\Bon\AppData\Local\Temp\ts-node-dev-hook-9024418715050684.js:69:33)
at Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
at require.extensions.<computed> (C:\Users\Bon\AppData\Local\Temp\ts-node-dev-hook-9024418715050684.js:71:20)
[ERROR] 20:56:46 Error: Cannot find module './jobs.resolver'
Require stack:
- B:\jrevsols\jrevsolsBE\src\resolvers\index.ts
- B:\jrevsols\jrevsolsBE\src\index.ts
Not really sure why this is happening and searching the issue most of them are unreleated

NodeJS - TypeError [ERR_INVALID_ARG_TYPE]: The “path” argument must be of type string. Received undefined (mkdirp module nodejs)

I have a Node/Angular project that won't run because of this error. I am getting the following error:
TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined
More context for that error:
PS C:\Users\Vinay\retail-billpay-node> node server
internal/validators.js:124
throw new ERR_INVALID_ARG_TYPE(name, 'string', value);
^
TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined
at validateString (internal/validators.js:124:11)
at resolve (path.js:139:9)
at pathArg (C:\Users\Vinay\retail-billpay-node\node_modules\mkdirp\lib\path-arg.js:15:10)
at mkdirp (C:\Users\Vinay\retail-billpay-node\node_modules\mkdirp\index.js:10:10)
at Object.<anonymous> (C:\Users\Vinay\retail-billpay-node\app\helpers\winston.js:26:3)
at Module._compile (internal/modules/cjs/loader.js:1063:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
at Module.load (internal/modules/cjs/loader.js:928:32)
at Function.Module._load (internal/modules/cjs/loader.js:769:14)
at Module.require (internal/modules/cjs/loader.js:952:19)
at require (internal/modules/cjs/helpers.js:88:18)
at Object.<anonymous> (C:\Users\Vinay\retail-billpay-node\app\services\LogService.js:9:17)
at Module._compile (internal/modules/cjs/loader.js:1063:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
at Module.load (internal/modules/cjs/loader.js:928:32)
at Function.Module._load (internal/modules/cjs/loader.js:769:14) {
code: 'ERR_INVALID_ARG_TYPE'
}
And here is my package.json if it helps:
{
"name": "retail-billpay-node",
"version": "1.0.0",
"description": "start your node express app from this boilerplate code",
"main": "server.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "siddhant-np",
"license": "ISC",
"dependencies": {
"async": "2.6.1",
"bluebird": "3.5.3",
"body-parser": "1.18.3",
"crypto": "1.0.1",
"csvtojson": "2.0.8",
"dotenv": "6.0.0",
"express": "4.16.3",
"extract-zip": "1.6.7",
"imap-simple": "4.3.0",
"ioredis": "4.6.2",
"kafka-node": "^5.0.0",
"lodash": "4.17.10",
"md5": "2.2.1",
"mkdirp": "0.5.1",
"moment": "2.22.2",
"moment-timezone": "0.5.21",
"mongoose": "5.2.9",
"nodemailer": "5.1.1",
"otp.js": "1.1.0",
"request": "2.87.0",
"util": "0.11.1",
"winston": "3.0.0",
"winston-daily-rotate-file": "3.2.1",
"xlsx": "0.14.1",
"xml-parse": "0.3.1",
"xml2js": "0.4.19",
"xmlbuilder": "10.0.0"
}
}
OK, I figured out the issue. I thought the error was telling me that path was undefined. When it fact it was saying the variables passed into path.join() were undefined. And that was because I forgot to add my .env file to the root so it could grab those variables.
Since it was an enterprise project so they don't keep .env file in the source code, I asked them and put it root.

Non-deterministic behavior of npm

After running npm install, I have noticed that sometimes package-lock.json changes.
This section:
"dependencies": {
"websocket": {
"version": "git://github.com/frozeman/WebSocket-Node.git#6c72925e3f8aaaea8dc8450f97627e85263999f2",
"from": "git://github.com/frozeman/WebSocket-Node.git#6c72925e3f8aaaea8dc8450f97627e85263999f2",
"requires": {
"debug": "^2.2.0",
"nan": "^2.3.3",
"typedarray-to-buffer": "^3.1.2",
"yaeti": "^0.0.6"
}
}
}
}
Changes to this:
"dependencies": {
"websocket": {
"version": "git://github.com/frozeman/WebSocket-Node.git#6c72925e3f8aaaea8dc8450f97627e85263999f2",
"from": "git://github.com/frozeman/WebSocket-Node.git#6c72925e3f8aaaea8dc8450f97627e85263999f2",
"requires": {
"debug": "^2.2.0",
"nan": "^2.3.3"
}
}
}
}
And when that happens, I get a runtime error:
module.js:538
throw err;
^
Error: Cannot find module 'typedarray-to-buffer'
at Function.Module._resolveFilename (module.js:536:15)
at Function.Module._load (module.js:466:25)
at Module.require (module.js:579:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (C:\Users\...\node_modules\web3-providers-ws\node_modules\websocket\lib\W3CWebSocket.js:18:16)
at Module._compile (module.js:635:30)
at Object.Module._extensions..js (module.js:646:10)
at Module.load (module.js:554:32)
at tryModuleLoad (module.js:497:12)
at Function.Module._load (module.js:489:3)
After some debugging, this error is for require("web3") in my code.
Here is the relevant section in my package.json file:
"devDependencies": {
"chai": "^4.1.2",
"chai-as-promised": "^7.0.0",
"bignumber.js": "^7.0.0",
"decimal.js": "^10.0.0",
"web3": "1.0.0-beta.34",
"ethereumjs-testrpc-sc": "6.1.2",
"ganache-cli": "6.1.0",
"solidity-coverage": "0.4.14",
"truffle": "4.1.3"
}
How can I resolve this, and why does npm work differently from time to time?

node.js app azure deployment from bitbucket

I am getting following error when i try to deploy nodejs app from bitbucket.
Command: "D:\home\site\deployments\tools\deploy.cmd"
Handling node.js deployment.
KuduSync.NET from: 'D:\home\site\repository' to: 'D:\home\site\wwwroot'
undefined:38
}
^
An error has occurred during web site deployment.
SyntaxError: Unexpected token } in JSON at position 1090
at Object.parse (native)
at Object.<anonymous> (D:\Program Files (x86)\SiteExtensions\Kudu\63.60712.2926\bin\Scripts\selectNodeVersion.js:179:44)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.runMain (module.js:604:10)
at run (bootstrap_node.js:394:7)
at startup (bootstrap_node.js:149:9)
undefined:38\r\n}\r\n^\r\n\r\nSyntaxError: Unexpected token } in JSON at position 1090\r\n at Object.parse (native)\r\n at Object.<anonymous> (D:\Program Files (x86)\SiteExtensions\Kudu\63.60712.2926\bin\Scripts\selectNodeVersion.js:179:44)\r\n at Module._compile (module.js:570:32)\r\n at Object.Module._extensions..js (module.js:579:10)\r\n at Module.load (module.js:487:32)\r\n at tryModuleLoad (module.js:446:12)\r\n at Function.Module._load (module.js:438:3)\r\n at Module.runMain (module.js:604:10)\r\n at run (bootstrap_node.js:394:7)\r\n at startup (bootstrap_node.js:149:9)\r\nD:\Program Files (x86)\SiteExtensions\Kudu\63.60712.2926\bin\Scripts\starter.cmd "D:\home\site\deployments\tools\deploy.cmd"
Using node 6.9.1
package.json
{
"name": "example",
"version": "1.0.0",
"description": "REST APIs for example",
"main": "app.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "git+abc"
},
"author": "abc",
"license": "ISC",
"homepage": "abc#readme",
"dependencies": {
"azure-storage": "^2.1.0",
"body-parser": "^1.17.1",
"change-case": "^3.0.1",
"dateformat": "^2.0.0",
"dotenv": "^4.0.0",
"express": "^4.15.2",
"jsonwebtoken": "^7.3.0",
"minimist": "^1.2.0",
"morgan": "^1.8.1",
"mssql": "^4.0.1",
"multer": "^1.3.0",
"nconf": "^0.8.4",
"node-friendly-response": "^3.1.4",
"request": "^2.81.0",
"require-dir": "^0.3.1",
"swagger-node-express": "^2.1.3",
"tedious": "^2.0.0",
"tedious-promises": "^0.4.1",
"underscore": "^1.8.3",
"winston": "^2.3.1"
}
}
Is it because of the node modules which i have used?
Or is it the problem during the loading of modules?
It seems that your package.json is not a valid JSON.
Update:
Kudu uses the following code to read the package.json file, see line 179 of selectNodeVersion.js.
json = existsSync(packageJson) && JSON.parse(fs.readFileSync(packageJson, 'utf8'));
So, before you push the package.json to github, you can use the code below to verify the file on your local:
var fs = require("fs");
var json = JSON.parse(fs.readFileSync("./package.json", 'utf8'));
console.log(json);
For example, I added one more } at line 38 in package.json your provided above, I would get the same error as yours:
Or you can just use the command npm install to check it:

keystone deployment fails on azure

I have an azure web-app and deploying my keystone app to azure from github.
Unfortunately I end up in an 500 error:
Tue May 23 2017 19:36:05 GMT+0000 (Coordinated Universal Time): Application has thrown an uncaught exception and is terminated:
Error: ENOENT: no such file or directory, scandir 'D:\home\site\wwwroot\C:\DWASFiles\Sites\chronasWebApp\DynamicCache\wwwroot\routes\api'
at Error (native)
at Object.fs.readdirSync (fs.js:945:18)
at importer (C:\DWASFiles\Sites\chronasWebApp\DynamicCache\wwwroot\node_modules\keystone\lib\core\importer.js:32:6)
at Object.<anonymous> (C:\DWASFiles\Sites\chronasWebApp\DynamicCache\wwwroot\routes\index.js:37:7)
at Module._compile (module.js:541:32)
at Object.Module._extensions..js (module.js:550:10)
at Module.load (module.js:458:32)
at tryModuleLoad (module.js:417:12)
at Function.Module._load (module.js:409:3)
at Module.require (module.js:468:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (C:\DWASFiles\Sites\chronasWebApp\DynamicCache\wwwroot\keystone.js:59:24)
at Module._compile (module.js:541:32)
at Object.Module._extensions..js (module.js:550:10)
at Module.load (module.js:458:32)
at tryModuleLoad (module.js:417:12)
How knows what the issue is?
This is the app we deploy:
https://github.com/aumanjoa/chronas-community
package.json:
{
"name": "chronas",
"version": "2.0.0",
"private": true,
"repository": {
"type": "git",
"url": "https://github.com/daumann/chronas-community.git"
},
"dependencies": {
"async": "^2.4.1",
"babel-core": "^6.24.1",
"babel-plugin-syntax-object-rest-spread": "^6.13.0",
"babel-plugin-transform-object-rest-spread": "^6.23.0",
"babel-preset-es2015": "^6.24.1",
"babel-preset-react": "^6.24.1",
"babel-register": "^6.24.1",
"babelify": "^7.3.0",
"body-parser": "^1.17.2",
"browserify-middleware": "^7.1.0",
"classnames": "^2.2.5",
"connect-mongo": "^1.3.2",
"crypto": "0.0.3",
"dotenv": "^4.0.0",
"express-graphql": "^0.6.5",
"graphql": "^0.9.6",
"graphql-relay": "^0.5.1",
"gulp": "^3.9.1",
"gulp-zip": "^4.0.0",
"jade": "^1.11.0",
"keystone": "https://github.com/keystonejs/keystone.git#f3083c",
"lodash": "^4.17.4",
"log4js": "^1.1.1",
"moment": "^2.18.1",
"newrelic": "^1.39.1",
"passport": "^0.3.2",
"passport-facebook": "^2.1.1",
"passport-github": "^1.1.0",
"passport-google-oauth": "^1.0.0",
"passport-twitter": "^1.0.4",
"react": "^15.5.4",
"react-dom": "^15.5.4",
"request": "^2.81.0",
"store-prototype": "^1.1.1",
"superagent": "^3.5.2",
"underscore": "^1.8.3"
},
"engines": {
"node": "6.2.2",
"npm": "3.9.5"
},
"scripts": {
"start": "node keystone.js",
"print-graphql-schema": "babel-node ./graphql/scripts/printSchema.js"
}
}
issue was related to this bug
Azure and node js __dirname
fixed the issue by updating to new node version.
"node": "6.10.0",
"npm": "3.10.10"

Resources