Basic db-mysql setup error - node.js

I just started using node.js for my project and tried making a connection to MySQL and inserting basic values. But I keep getting the following error:
node.js:201
throw e; // process.nextTick error, or 'error' event on first tick
^
Error: Unable to load shared library /Users/****/nodeJS/node_modules/db-mysql/build/Release/mysql_bindings.node
at Object..node (module.js:472:11)
at Module.load (module.js:348:31)
at Function._load (module.js:308:12)
at Module.require (module.js:354:17)
at require (module.js:370:17)
at Object.<anonymous> (/Users/****/nodeJS/node_modules/db-mysql/db-mysql.js:18:15)
at Module._compile (module.js:441:26)
at Object..js (module.js:459:10)
at Module.load (module.js:348:31)
at Function._load (module.js:308:12)
I did as was instructed, I specified the MYSQL_CONFIG environment variable:
$ export MYSQL_CONFIG=/usr/local/mysql/bin/mysql_config

maybe it's too late and I hope you solved this problem on your own, but it might be useful for other people experiencing the same issue.
What I did to solve it is to set the following variable:
export DYLD_LIBRARY_PATH=<your absolute path to mysql lib folder>
in my case it is:
export DYLD_LIBRARY_PATH=/usr/local/mysql-5.5.25-osx10.6-x86_64/lib/
Tested on MacOS Lion 10.7.4

Related

Cannot find module 'm3u8stream/lib/parse-time'

is there anyway to fix this? I've been trying to resolve this myself but I give up
throw err;
^
Error: Cannot find module 'm3u8stream/lib/parse-time'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:582:15)
at Function.Module._load (internal/modules/cjs/loader.js:508:25)
at Module.require (internal/modules/cjs/loader.js:637:17)
at require (internal/modules/cjs/helpers.js:22:18)
at Object.<anonymous> (/rbd/pnpm-volume/71b5ddd8-2a78-46fc-aba4-68049f14880d/node_modules/.registry.npmjs.org/ytdl-core/1.0.0/node_modules/ytdl-core/lib/info-extras.js:5:21)
at Module._compile (internal/modules/cjs/loader.js:701:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:712:10)
at Module.load (internal/modules/cjs/loader.js:600:32)
at tryModuleLoad (internal/modules/cjs/loader.js:539:12)
at Function.Module._load (internal/modules/cjs/loader.js:531:3)
This works for me, at the root of the project:
cp -r ./node_modules/m3u8stream/dist ./node_modules/m3u8stream/lib
I really don't understand why, I assume is some bug of versions, (mentioned in the previous comments) cause for some reason it needs the both folders dist and lib (with the same content apparently)
Solved by: Chills
Comment: did you install parse-time?
Answer: no I didn't, I did get it installed but also I've learned from a friend about ytdl-core update required dist instead of lib
Source: https://github.com/fent/node-ytdl-core/pull/520
Solution:
packages needed installing: m3u8stream and parse-time
code needed in main file:
const m3u8stream = require('m3u8stream');
const parseTime = require('m3u8stream/dist/parse-time');

Can not find module users.json error in express-gateway

After installing express-gateway, when I create API gateway using following command,
eg gateway create
I am getting following error.
[EG:config] error: Cannot find module 'C:\My Content\Microservice Projects\FIFA Team Selection\config\models\users.json'
C:\My Content\Microservice Projects\FIFA Team Selection\node_modules\express-gateway\lib\config\index.js:15
throw err;
^
Error: Cannot find module 'C:\My Content\Microservice Projects\FIFA Team Selection\config\models\users.json'
at Function.Module._resolveFilename (module.js:538:15)
at Function.Module._load (module.js:468:25)
at Module.require (module.js:587:17)
at require (internal/module.js:11:18)
at forEach.model (C:\My Content\Microservice Projects\FIFA Team Selection\node_modules\express-gateway\lib\config\config.js:68:27)
at Array.forEach (<anonymous>)
at Config.loadModels (C:\My Content\Microservice Projects\FIFA Team Selection\node_modules\express-gateway\lib\config\config.js:65:61)
at Object.<anonymous> (C:\My Content\Microservice Projects\FIFA Team Selection\node_modules\express-gateway\lib\config\index.js:11:10)
at Module._compile (module.js:643:30)
at Object.Module._extensions..js (module.js:654:10)
child_process.js:624
throw err;
^
Error: Command failed: C:\My Content\Microservice Projects\FIFA Team Selection\node_modules\.bin\eg.cmd gateway create
at checkExecSyncError (child_process.js:601:13)
at execFileSync (child_process.js:621:13)
at exports.executeInScope.env (C:\Users\bmaheshwari\AppData\Roaming\npm\node_modules\express-gateway\bin\execution-scope.js:37:5)
at Object.exports.bootstrap (C:\Users\bmaheshwari\AppData\Roaming\npm\node_modules\express-gateway\bin\environment.js:11:7)
at Object.<anonymous> (C:\Users\bmaheshwari\AppData\Roaming\npm\node_modules\express-gateway\bin\index.js:9:46)
at Module._compile (module.js:643:30)
at Object.Module._extensions..js (module.js:654:10)
at Module.load (module.js:556:32)
at tryModuleLoad (module.js:499:12)
at Function.Module._load (module.js:491:3)
I tried removing node_modules folder and re-installing it again, but issue persists.
This can usually happen when something is wrong during the scaffolding/creation section. I can also see you're running the command from Windows.
We had different users complaining about some weird CLI problems with that operating system which I'm not actively supporting right now.
It shouldn't be too hard to copy that file from the repository and place it in the right directory. I know it's a workaround, but it should do the trick.

NodeJS Error In Constructor Language Only Present On Ubuntu

I am trying to get a particular npm package to run on Ubuntu 16.04. I am currently running the most up-to-date versions of nodejs and npm, as well as the package (turndown).
Here is the error that I get:
root#ubuntu-s-1vcpu-1gb-nyc1-01:/usr/server# nodejs index.js
/usr/server/node_modules/jsdom/lib/api.js:10
const { URL } = require("whatwg-url");
^
SyntaxError: Unexpected token {
at exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:374:25)
at Object.Module._extensions..js (module.js:417:10)
at Module.load (module.js:344:32)
at Function.Module._load (module.js:301:12)
at Module.require (module.js:354:17)
at require (internal/module.js:12:17)
at createHTMLParser (/usr/server/node_modules/turndown/lib/turndown.cjs.js:529:17)
at Object.<anonymous> (/usr/server/node_modules/turndown/lib/turndown.cjs.js:537:60)
at Module._compile (module.js:410:26)
The error states it occurs within the "turndown" package and is due to the language in the constructor. What is confusing to me is that this runs on Fedora 27 without error.
What could be causing the difference in behavior?
The answer to this question was to update my version of NodeJS. I ran into another error now, but it is package related.

upgraded node to v0.8 and started receiving an error for sys/util

I upgraded from node v0.6.12 to 0.80 and started receiving the error below - I have removed the sys module from the import but am still getting the error. Any helpful hints would be helpful. I am not suing stylus either.
path.exists is now called `fs.exists`.
sys.js:1
throw new Error(
Error: The "sys" module is now called "util".
at sys.js:1:69
at NativeModule.compile (node.js:602:5)
at Function.NativeModule.require (node.js:570:18)
at Function.Module._load (module.js:297:25)
at Module.require (module.js:362:17)
at require (module.js:378:17)
at Object.<anonymous> (/node/node_modules/stylus/lib/token.js:12:15)
at Module._compile (module.js:449:26)
at Object.Module._extensions..js (module.js:467:10)
at Module.load (module.js:356:32)
Upgrade to node v0.8.1. It will solve your problem

Cannot find module 'now' - nowjs and nodejs

I installed nodejs in my home folder (/home/myname/). No problems so far.
Then I installed nowjs and there was one warning:
Checking for node path: not found
Now when I try this example: http://nowjs.com/doc/example I get the error:
node.js:201
throw e; // process.nextTick error, or 'error' event on first tick
^ Error: Cannot find module 'now'
at Function._resolveFilename (module.js:334:11)
at Function._load (module.js:279:25)
at Module.require (module.js:357:17)
at require (module.js:368:17)
at Object.<anonymous> (/var/www/www.mydomain.de/htdocs/helloworld_server.js:7:13)
at Module._compile (module.js:432:26)
at Object..js (module.js:450:10)
at Module.load (module.js:351:31)
at Function._load (module.js:310:12)
at Array.0 (module.js:470:10)
Something with the paths is wrong I guess...anyone knows how to fix this?
Thanks
try this before :
npm config set global true && \
echo 'export NODE_PATH="'$(npm root -g)'"' >> ~/.bashrc && \
. ~/.bashrc

Resources