what is the cause of this error message "Error: Cannot find module '../models'" from nodejs+elasrticsearch github repo - node.js

I'm trying to setup node.js and Elasticsearch together in a docker container,
I've been following this post to the letter,until to the section of launching the application
when I type
docker-compose up
I keep getting this node.js error that is saying models module is not found
tqd-node | { Error: Cannot find module '../models'
this is the first few lines of the error message
tqd-elasticsearch is up-to-date
Starting tqd-node ... done
Attaching to tqd-elasticsearch, tqd-node
tqd-elasticsearch | WARNING: no logs are available with the 'none' log driver
tqd-node |
tqd-node | > nodejselastic#1.0.0 start /usr/src/app
tqd-node | > pm2-runtime start ./src/main.js --name node_app
tqd-node |
tqd-node | 2019-12-14T23:09:56: PM2 log: Launching in no daemon mode
tqd-node | 2019-12-14T23:09:56: PM2 log: App [node_app:0] starting in -fork mode-
tqd-node | 2019-12-14T23:09:56: PM2 log: App [node_app:0] online
tqd-node | { Error: Cannot find module '../models'
tqd-node | at Function.Module._resolveFilename (internal/modules/cjs/loader.js:582:15)
tqd-node | at Module.Hook._require.Module.require (/usr/local/lib/node_modules/pm2/node_modules/require-in-the-middle/index.js:51:29)
so I downloaded the full code from this GitHub repository(the-quotes-database)
but I still got the same error
I did try to change the path in controller file here
const model = require("../models");
I thought maybe it needs the full c:// path, but that didn't change the error message.
when I do hover over models in VSC editor it shows that it is the correct path.
so my question is : is this a bug in the repo or is the issue with my windows docker configuration?
I successfully managed to create simple python containers with docker,
so I'm not sure what is the root cause of this error and how to fix it.

update: I will answer here in case anyone finds a similar issue.
I installed docker and downloaded the files and repeated the steps on my Ubuntu laptop and it worked!
so the downloaded files were not prepared to work on Windows, it is not a bug in the repo if you have Linux.

Related

Why pm2 logs not showing real time in Node js?

I have tried used pm2 modules and use pm2 logs, early pm2 logs are real time and show me everything console it but from today show only at least 15 lines?( can change this line more or less but not show real time "pm2 logs --lines 1000" show at least 1000 but I want show real time logs )
when run "pm2 logs" showing :
[TAILING] Tailing last 15 lines for [all] processes (change the value with --lines option)
C:\Users\user.pm2\pm2.log last 15 lines:
PM2 | Error while getting network statistics Error: not supported
PM2 | at process.nextTick (D:\wamp64\www...\pm2\node_modules\systeminformation\lib\filesystem.js:418:21)
PM2 | at process._tickCallback (internal/process/next_tick.js:61:11)
PM2 | Error while getting network statistics Error: not supported
PM2 | at process.nextTick (C:\Users\user\AppData\Roaming\npm\node_modules\pm2\node_modules\systeminformation\lib\filesystem.js:418:21)
PM2 | at process._tickCallback (internal/process/next_tick.js:61:11)
PM2 | Error while getting network statistics Error: not supported
PM2 | at process.nextTick (D:\wamp64\www...\pm2\node_modules\systeminformation\lib\filesystem.js:418:21)
PM2 | at process._tickCallback (internal/process/next_tick.js:61:11)
PM2 | Error while getting network statistics Error: not supported
PM2 | at process.nextTick (C:\Users\user\AppData\Roaming\npm\node_modules\pm2\node_modules\systeminformation\lib\filesystem.js:418:21)
PM2 | at process._tickCallback (internal/process/next_tick.js:61:11)
PM2 | Error while getting network statistics Error: not supported
PM2 | at process.nextTick (D:\wamp64\www...\pm2\node_modules\systeminformation\lib\filesystem.js:418:21)
PM2 | at process._tickCallback (internal/process/next_tick.js:61:11)
Why show this error and how resolve it? and why not showing real time logs for me?
all work done :
kill pm2, restart it, update it, update node modules, flush pm2
Thank's

jsreport failing on looking up extensions

So I recently started working on a linux machine (ubuntu 16.04) and followed the installation instructions here http://jsreport.net/downloads/. When I run npm start --production I get
2016-09-13T16:51:57.134Z - info: Initializing jsreport in production mode using configuration file prod.config.json
2016-09-13T16:51:57.138Z - info: Setting process based strategy for rendering. Please visit http://jsreport.net/learn/configuration for information how to get more performance.
2016-09-13T16:51:57.146Z - info: Searching for available extensions in /home/ross/rifiniti/optimo_ui/
2016-09-13T16:51:57.152Z - info: Extensions location cache not found, crawling directories
2016-09-13T16:51:57.317Z - error: Error occured during reporter init Error: ENOENT, no such file or directory '/home/ross/rifiniti/optimo_ui/ember/tmp/tree_merger-tmp_dest_dir-2yGnPLMA.tmp/optimo-ui/config'
at Error (native)
at Object.fs.statSync (fs.js:801:18)
at /home/ross/rifiniti/optimo_ui/node_modules/jsreport/node_modules/jsreport-core/lib/util/util.js:51:21
at Array.forEach (native)
at Object.exports.walkSync (/home/ross/rifiniti/optimo_ui/node_modules/jsreport/node_modules/jsreport-core/lib/util/util.js:44:10)
at /home/ross/rifiniti/optimo_ui/node_modules/jsreport/node_modules/jsreport-core/lib/extensions/locationCache.js:50:20
From previous event:
at /home/ross/rifiniti/optimo_ui/node_modules/jsreport/node_modules/jsreport-core/lib/reporter.js:90:8
From previous event:
at Reporter.init (/home/ross/rifiniti/optimo_ui/node_modules/jsreport/node_modules/jsreport-core/lib/reporter.js:69:30)
at Reporter.reporter.init (/home/ross/rifiniti/optimo_ui/node_modules/jsreport/lib/extendInit.js:8:21)
at Object.<anonymous> (/home/ross/rifiniti/optimo_ui/server.js:1:85)
And I have no idea why. It was working fine on mac but now it is looking for this non-existent tmp file in ember. I'm at a loss, any help would be greatly appreciated!
SOLVED!
All I had to do was remove the tmp directory in ember and it worked.

Grunt error when running Sails.js app in Amazon ElasticBeanstalk

I am moving a Sails.js app hosted on Heroku to Amazon ElasticBeanstalk. When the application launches, it throws the following Grunt error (pulled from eb logs):
info: Sails <| .-..-.
info: v0.11.5 |\
info: /|.\
info: / || \
info: ,' |' \
info: .-'.-==|/_--'
info: `--'-------'
info: __---___--___---___--___---___--___
info: ____---___--___---___--___---___--___-__
info:
info: Server lifted in `/var/app/current`
info: To see your app, visit http://localhost:8081
info: To shut down Sails, press <CTRL> + C at any time.
debug: --------------------------------------------------------
debug: :: Mon Feb 29 2016 08:21:46 GMT+0000 (UTC)
debug: Environment : development
debug: Port : 8081
debug: --------------------------------------------------------
error: ** Grunt :: An error occurred. **
error:
------------------------------------------------------------------------
>> FileError: '../bower_components/bootstrap/less/grid.less' wasn't found in assets/styles/importer.less on line 9, column 1:
>> 8 // Import Bootstrap
>> 9 #import "../bower_components/bootstrap/less/grid.less";
>> 10 #import "../bower_components/bootstrap/less/mixins.less";
Warning: Error compiling assets/styles/importer.less
Aborted due to warnings.
Running "less:dev" (less) task
------------------------------------------------------------------------
error: Looks like a Grunt error occurred--
error: Please fix it, then **restart Sails** to continue running tasks (e.g. watching for changes in assets)
error: Or if you're stuck, check out the troubleshooting tips below.
error: Troubleshooting tips:
error:
error: *-> Are "grunt" and related grunt task modules installed locally? Run `npm install` if you're not sure.
error:
error: *-> You might have a malformed LESS, SASS, CoffeeScript file, etc.
error:
error: *-> Or maybe you don't have permissions to access the `.tmp` directory?
error: e.g., `/var/app/current/.tmp` ?
error:
error: If you think this might be the case, try running:
error: sudo chown -R 497 /var/app/current/.tmp
The same code runs fine on my local development laptop and on Heroku but not on ElasticBeanstalk. Why is it unable to find the bootstrap files? This being a PaaS, I can't even run the recommended sudo chown command that the log recommended. Also to be clear, I have the following command in my package.json file:
"scripts": {
"postinstall": "bower install; grunt build",
"debug": "node debug app.js",
"start": "node app.js"
}
I have instructed the script to run bower install after the NPM packages are installed in the machine. None of the images in my /assets folder seem to load either. Not sure what's going on. Please help.

trouble in sails lift on AWS server

when I am running the project with sails lift then it shows -
Aborted due to warnings.
Running "sails-linker:devTpl" (sails-linker) task
padding length 4
Warning: Unable to write "views/layout.ejs" file (Error code: EACCES).
------------------------------------------------------------------------
error: Looks like a Grunt error occurred--
error: Please fix it, then **restart Sails** to continue running tasks (e.g. watching for changes in assets)
error: Or if you're stuck, check out the troubleshooting tips below.
error: Troubleshooting tips:
error:
error: *-> Are "grunt" and related grunt task modules installed locally? Run `npm install` if you're not sure.
error:
error: *-> You might have a malformed LESS, SASS, CoffeeScript file, etc.
error:
error: *-> Or maybe you don't have permissions to access the `.tmp` directory?
error: e.g., `/var/myproj/.tmp` ?
error:
error: If you think this might be the case, try running:
error: sudo chown -R 1000 /var/myproj/.tmp
I have tried all the given steps like provide access to .tmp and npm install
and when I am debugging the code by sails debus is shows :
Grunt :: Error: listen EADDRINUSE :::5858
at Object.exports._errnoException (util.js:860:11)
at exports._exceptionWithHostPort (util.js:883:20)
at Agent.Server._listen2 (net.js:1234:14)
at listen (net.js:1270:10)
at Agent.Server.listen (net.js:1366:5)
at Object.start (_debug_agent.js:21:9)
at startup (node.js:72:9)
at node.js:972:3
Strange part is its running on my local system and on normal(other) server very fine and correctly working.
You'll need to chmod the views directory

multiple node.js + always = Error: watch EMFILE

I'm running three node.js applications on one server, all using Foreman to start up the apps through always.js.
Under zero load, one of my apps consistently throws the error Error: watch EMFILE and restarts. That application still works though, despite constantly throwing that error... I've tried to find more information about this error, but there's not a whole lot out there ("too many files open" or "increase ulimit".)
My question is: why would this be happening on an idle web application - and why just one out of three? It's not doing anything... Is it an issue with always.js? (There are two other node apps running through always on this machine though...) Just looking for some info as to what is causing this error, if it's serious, and how it can be resolved.
Thanks!
FYI, here is a relevant excerpt from the console:
01:17:07 web.1 | app listening on http://0.0.0.0:5000
01:17:07 web.1 | NODE_ENV = development
01:17:07 web.1 | opened connection to database!
01:17:07 web.1 | [always] Error: watch EMFILE
01:17:07 web.1 | [always] Error: watch EMFILE
01:17:07 web.1 | at errnoException (fs.js:636:11)
01:17:07 web.1 | at FSWatcher.start (fs.js:663:11)
01:17:07 web.1 | at Object.watch (fs.js:691:11)
01:17:07 web.1 | at Object.oncomplete (/home/jesse/local/nodev0.6.14/lib/node_modules/always/lib/monitor.js:62:36)
01:17:07 web.1 | [always] Restarting app.js with Node
I don't have experience with always.js but got similar errors with other node utilities that use the fs.watch command, which in turn uses linux's inotify API.
You might want to try checking the settings for inotify then:
cat /proc/sys/fs/inotify/max_user_instances
If the file exists, setting it to a higher value might help:
echo 8704 > /proc/sys/fs/inotify/max_user_instances

Resources