Unable to start node.js application written with graphql - node.js

I have an application written in node.js with graphql, it is running on ubuntu sever, however, i cloned the code onto my local windows 10, installed all packages, and node environment, but when I try to start the app with "node index.js" I got the following error.
TypeError [ERR_INVALID_ARG_TYPE]: The "chunk" argument must be one of type string or Buffer. Received type object
at validChunk (_stream_writable.js:263:10)
at WriteStream.Writable.write (_stream_writable.js:297:21)
at Object.<anonymous> (D:/MyProjects/appletree/apple-tree-backend/configs/constants.js:5:17)
at Module._compile (internal/modules/cjs/loader.js:776:30)
at loader (D:\MyProjects\appletree\apple-tree-backend\node_modules\babel- register\lib\node.js:144:5)
at Object.require.extensions.(anonymous function) [as .js] (D:\MyProjects\appletree\apple- tree-backend\node_modules\babel-register\lib\node.js:154:7)
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)
Emitted 'error' event at:
at errorOrDestroy (internal/streams/destroy.js:107:12)
at validChunk (_stream_writable.js:266:5)
at WriteStream.Writable.write (_stream_writable.js:297:21)
[... lines matching original stack trace ...]
at Function.Module._load (internal/modules/cjs/loader.js:585:3)

Thanks for answering, I figured out the issue later as I looked into the code, the project used dotenv package which requires a .env file and this file is not included in the source code that's why I couldn't start the code on my local. I got the .env file from the production server and now the code can run on my local , thanks everyone.

Related

how can i fix this error that nodemon keep on showing

i following an express.js tutorial andd after some code and functionalities with api requests i followed exactly how he changed the code that handles these requests into a seperate js file in another folder just to clean up the code but after i did that this error showed up
i tried changing the file name , i tried removing the node-modules folder and running npm install again and i tried installing the module with the issue
internal/modules/cjs/loader.js:638
throw err;
^
Error: Cannot find module '/routes/api/members'
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:690:17)
at require (internal/modules/cjs/helpers.js:25:18)
at Object.<anonymous> (C:\Users\Get_Rico\Desktop\crashcoursse\index.js:11:25)
at Module._compile (internal/modules/cjs/loader.js:776:30)
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)
[nodemon] app crashed - waiting for file changes before starting...
i expect nodemon to save the changes and work just fine with no errors just like what happened in the tutorial
It appears the error is probably coming from this line of code and it's telling you that it can't find the '/routes/api/members' module file.
And, this would not be working because you're trying to load a local module without a proper path name. If no path is specified, then it tries to load a global or built-in module. If that module is in the current directory, then you should use the correct path:
const yourModule = './routes/api/members';

Electron: TypeError: Cannot create property 'default' on symbol 'Symbol(nodejs.util.inspect.custom)'

I've developed an electron app with following tech stack:
NodeJS (10.15) with Babel to allow ES6 import/export syntax.
Sequelize on SQLite and GraphQL to handle an internal database.
ReactJS (bundled) for views.
I've configured everything to work with Electron and running "electron" command in project root folder works without errors.
Now i'm trying to distribute it using this tutorial: https://electronjs.org/docs/tutorial/application-distribution
So i've simply downloaded the 4.1.4 binaries for windows and moved the project folder under resources/app/
But running the electron.exe i've the following error:
App threw an error during load
TypeError: Cannot create property 'default' on symbol 'Symbol(nodejs.util.inspect.custom)'
at Object.<anonymous> (C:\workspace\myapp\resources\app\node_modules\graphql\jsutils\nodejsCustomInspectSymbol.js:18:84)
at Object.<anonymous> (C:\workspace\myapp\resources\app\node_modules\graphql\jsutils\nodejsCustomInspectSymbol.js:20:3)
at Module._compile (internal/modules/cjs/loader.js:711:30)
at Module._compile (C:\workspace\myapp\resources\app\node_modules\pirates\lib\index.js:83:24)
at Module._extensions..js (internal/modules/cjs/loader.js:722:10)
at Object.newLoader [as .js] (C:\workspace\myapp\resources\app\node_modules\pirates\lib\index.js:88:7)
at Module.load (internal/modules/cjs/loader.js:620:32)
at tryModuleLoad (internal/modules/cjs/loader.js:559:12)
at Function.Module._load (internal/modules/cjs/loader.js:551:3)
at Module.require (internal/modules/cjs/loader.js:658:17)
at require (internal/modules/cjs/helpers.js:20:18)
at Object.<anonymous> (C:\workspace\myapp\resources\app\node_modules\graphql\jsutils\defineToJSON.js:8:57)
at Object.<anonymous> (C:\workspace\myapp\resources\app\node_modules\graphql\jsutils\defineToJSON.js:36:3)
at Module._compile (internal/modules/cjs/loader.js:711:30)
at Module._compile (C:\workspace\myapp\resources\app\node_modules\pirates\lib\index.js:83:24)
at Module._extensions..js (internal/modules/cjs/loader.js:722:10)
at Object.newLoader [as .js] (C:\workspace\myapp\resources\app\node_modules\pirates\lib\index.js:88:7)
at Module.load (internal/modules/cjs/loader.js:620:32)
at tryModuleLoad (internal/modules/cjs/loader.js:559:12)
at Function.Module._load (internal/modules/cjs/loader.js:551:3)
at Module.require (internal/modules/cjs/loader.js:658:17)
at require (internal/modules/cjs/helpers.js:20:18)
i've also tried to run npx electron resources/app/ from binaries folder and i've got the same error.
So i think the issue is something about the paths.
i've also tried electron-packager and the error is the same because this tool does the same process of guide above.
What can i do to fix it?
UPDATE1: after some investigations i've found that babel causes the issues. I guess when you run a project from a parent folder. I'm trying to find a solution
i've solved using this kind of configuration for babel/register:
const rootPath=path.resolve(path.join(__dirname, "../../"));
require("#babel/register")({
root: rootPath,
extends: path.join(rootPath, '.babelrc'),
ignore: [/node_modules/],
only: [rootPath],
})

NodeJS-Electron-msnodesqlv8 - Error while loading binaries in msnodesqlv8

Context: I am building an electron app, which is querying a sql server (remote server) to get the data from table. I am using mssqlnodev8.
Error: When I start the electron app using npm start, I get the below error -
Uncaught Error: None of the binaries loaded successfully. Is your node
version either latest 4, 5, 6, 7, 8 or 9 ?
at failIfNoBinaryExported (C:\Users\t9sau2\Documents\NodeJs\Renewalverification\node_modules\msnodesqlv8\lib\bootstrap.js:63)
at Object.liveLoad (C:\Users\t9sau2\Documents\NodeJs\Renewalverification\node_modules\msnodesqlv8\lib\bootstrap.js:50)
at Object. (C:\Users\t9sau2\Documents\NodeJs\Renewalverification\node_modules\msnodesqlv8\lib\bootstrap.js:79)
at Object. (C:\Users\t9sau2\Documents\NodeJs\Renewalverification\node_modules\msnodesqlv8\lib\bootstrap.js:81)
at Module._compile (internal/modules/cjs/loader.js:711)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:722)
at Module.load (internal/modules/cjs/loader.js:620)
at tryModuleLoad (internal/modules/cjs/loader.js:559)
at Function.Module._load (internal/modules/cjs/loader.js:551)
at Module.require (internal/modules/cjs/loader.js:658)
Additional information about electron app -
I am using bootstrap for my UI. As per electron faq site, I have the below code in my entry html file
<script>
window.nodeRequire = require;
delete window.require;
delete window.exports;
delete window.module;
</script>
All the modules except electron (index.js - entry point) is imported with
nodeRequire
Analysis done till now -
The javascript logic to connect to database and fetch records are in
separate js file. When I execute the file with 'node file.js', it
works perfectly fine and returns records.
The node version is v9.8.0. Electron version is 3.0.2
I analyzed bootstrap.js file in node_modules\msnodesqlv8\lib\bootstrap.js, line number 63. It traced to below code
var files = require('fs').readdirSync(binaryDir)
I changed that too nodeRequire, but it didnt work.
I have checked similar issues in github but none of the resolutions helped.
UPDATED
I analyzed the bootstrap.js in msnodesqlv8. These are the different error messages
Error while exporting binary Error:
\?\C:\Users\t9sau2\Documents\NodeJs\Renewalverification\node_modules\msnodesqlv8\lib\bin\sqlserverv8.electron.v2.0.4.ia32.node
is not a valid Win32 application.
\?\C:\Users\t9sau2\Documents\NodeJs\Renewalverification\node_modules\msnodesqlv8\lib\bin\sqlserverv8.electron.v2.0.4.ia32.node
at process.module.(anonymous function) [as dlopen] (ELECTRON_ASAR.js:166:20)
at Object.Module._extensions..node (internal/modules/cjs/loader.js:740)
at Object.module.(anonymous function) [as .node] (ELECTRON_ASAR.js:166:20)
at Module.load (internal/modules/cjs/loader.js:620)
at tryModuleLoad (internal/modules/cjs/loader.js:559)
at Function.Module._load (internal/modules/cjs/loader.js:551)
at Module.require (internal/modules/cjs/loader.js:658)
at require (internal/modules/cjs/helpers.js:20)
at attemptToExportBinary (C:\Users\t9sau2\Documents\NodeJs\Renewalverification\node_modules\msnodesqlv8\lib\bootstrap.js:58)
at C:\Users\t9sau2\Documents\NodeJs\Renewalverification\node_modules\msnodesqlv8\lib\bootstrap.js:48
Error while exporting binary Error: The module
'\?\C:\Users\t9sau2\Documents\NodeJs\Renewalverification\node_modules\msnodesqlv8\lib\bin\sqlserverv8.electron.v2.0.4.x64.node'
was compiled against a different Node.js version using
NODE_MODULE_VERSION 57. This version of Node.js requires
NODE_MODULE_VERSION 64. Please try re-compiling or re-installing the
module (for instance, using npm rebuild or npm install).
at process.module.(anonymous function) [as dlopen] (ELECTRON_ASAR.js:166:20)
at Object.Module._extensions..node (internal/modules/cjs/loader.js:740)
at Object.module.(anonymous function) [as .node] (ELECTRON_ASAR.js:166:20)
at Module.load (internal/modules/cjs/loader.js:620)
at tryModuleLoad (internal/modules/cjs/loader.js:559)
at Function.Module._load (internal/modules/cjs/loader.js:551)
at Module.require (internal/modules/cjs/loader.js:658)
at require (internal/modules/cjs/helpers.js:20)
at attemptToExportBinary (C:\Users\t9sau2\Documents\NodeJs\Renewalverification\node_modules\msnodesqlv8\lib\bootstrap.js:58)
at C:\Users\t9sau2\Documents\NodeJs\Renewalverification\node_modules\msnodesqlv8\lib\bootstrap.js:48
Error while exporting binary Error:
\?\C:\Users\t9sau2\Documents\NodeJs\Renewalverification\node_modules\msnodesqlv8\lib\bin\sqlserverv8.node.v10.8.0.ia32.node
is not a valid Win32 application.
\?\C:\Users\t9sau2\Documents\NodeJs\Renewalverification\node_modules\msnodesqlv8\lib\bin\sqlserverv8.node.v10.8.0.ia32.node
at process.module.(anonymous function) [as dlopen] (ELECTRON_ASAR.js:166:20)
at Object.Module._extensions..node (internal/modules/cjs/loader.js:740)
at Object.module.(anonymous function) [as .node] (ELECTRON_ASAR.js:166:20)
at Module.load (internal/modules/cjs/loader.js:620)
at tryModuleLoad (internal/modules/cjs/loader.js:559)
at Function.Module._load (internal/modules/cjs/loader.js:551)
at Module.require (internal/modules/cjs/loader.js:658)
at require (internal/modules/cjs/helpers.js:20)
at attemptToExportBinary (C:\Users\t9sau2\Documents\NodeJs\Renewalverification\node_modules\msnodesqlv8\lib\bootstrap.js:58)
at C:\Users\t9sau2\Documents\NodeJs\Renewalverification\node_modules\msnodesqlv8\lib\bootstrap.js:48
I had raised this issue in github report of msnodesqlv8. The owner updated the version, which resolved the issue. github link - https://github.com/TimelordUK/node-sqlserver-v8/issues/80

Can't run node project after formatting my linux partition

As the title says, I formatted my linux partition where I used as web development environment. Mainly I used MongoDB and NodeJS and both of them are installed correctly. But when I try to execute my main.js I get an error log. It must be something extremely silly that I'm not reminded of. Any help is appreciated. Error log:
SyntaxError: Invalid or unexpected token
at new Script (vm.js:74:7)
at createScript (vm.js:246:10)
at Object.runInThisContext (vm.js:298:10)
at Module._compile (internal/modules/cjs/loader.js:657:28)
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)
Note that helpers.js is a node internal module.
Please download nodeJS command prompt for Linux or download by command
pacman -S nodejs npm
For More help : Visit the link
Node JS Installation Guide

Ghost blog, Error while running it on local machine

I have installed ghost blog on Openshift and created local copy to make some changes. I added new theme and deployed it back to openshift. Its working fine but I am not able to run this blog on my local machine.
If I run NPM start, I am getting following error:
> openshift-ghost-quickstart# start C:\Users\darklord\OneDrive\Business\mean
> node index
Unhandled rejection Error: Cannot find module 'C:\Users\darklord\OneDrive\Business\mean\node_modules\ghost\node_modules\sqlite3\lib\binding\node-v47-win32-x64\node_sqlite3.node'
at Function.Module._resolveFilename (module.js:339:15)
at Function.Module._load (module.js:290:25)
at Module.require (module.js:367:17)
at require (internal/module.js:16:19)
at Object.<anonymous> (C:\Users\darklord\OneDrive\Business\mean\node_modules\ghost\node_modules\sqlite3\lib\sqlite3.js:4:15)
at Module._compile (module.js:413:34)
at Object.Module._extensions..js (module.js:422:10)
at Module.load (module.js:357:32)
at Function.Module._load (module.js:314:12)
at Module.require (module.js:367:17)
at require (internal/module.js:16:19)
at Client_SQLite3.initDriver (C:\Users\darklord\OneDrive\Business\mean\node_modules\ghost\node_modules\knex\lib\dialects\sqlite3\index.js:41:24)
at new Client_SQLite3 (C:\Users\darklord\OneDrive\Business\mean\node_modules\ghost\node_modules\knex\lib\dialects\sqlite3\index.js:15:10)
at Knex.initialize (C:\Users\darklord\OneDrive\Business\mean\node_modules\ghost\node_modules\knex\knex.js:109:15)
at Knex (C:\Users\darklord\OneDrive\Business\mean\node_modules\ghost\node_modules\knex\knex.js:13:26)
at ConfigManager.set (C:\Users\darklord\OneDrive\Business\mean\node_modules\ghost\core\server\config\index.js:156:24)
at ConfigManager.init (C:\Users\darklord\OneDrive\Business\mean\node_modules\ghost\core\server\config\index.js:79:10)
at C:\Users\darklord\OneDrive\Business\mean\node_modules\ghost\core\server\config\index.js:273:30
at tryCatcher (C:\Users\darklord\OneDrive\Business\mean\node_modules\ghost\node_modules\bluebird\js\main\util.js:26:23)
at Promise._settlePromiseFromHandler (C:\Users\darklord\OneDrive\Business\mean\node_modules\ghost\node_modules\bluebird\js\main\promise.js:507:31)
at Promise._settlePromiseAt (C:\Users\darklord\OneDrive\Business\mean\node_modules\ghost\node_modules\bluebird\js\main\promise.js:581:18)
at Promise._settlePromises (C:\Users\darklord\OneDrive\Business\mean\node_modules\ghost\node_modules\bluebird\js\main\promise.js:697:14)
I though that this errpr has something to do with sqlite3 so I have uninstalled and installed it back but still same error.
Can someone let me know what mistake I am going ?
In case other people are running into this issue.
You are probably running a different node.js version on your local machine.
You could check manually in the {gostblog}\node_modules\ghost\node_modules\sqlite3\lib\binding\ folder if you have a different version than the node-v47-win32-x64 he is asking for.
Just reinstall the Ghost dependencies on your local machine to get it running.

Resources