node.js cannot find app.js after deployment to elastic beanstalk - node.js

I've just deployed my application to elastic beanstalk by doing an eb push.
My application isn't starting and the node.js logs say the following:
Error: Cannot find module '/var/app/current/dist/app.js'
at Function.Module._resolveFilename (module.js:336:15)
at Function.Module._load (module.js:278:25)
at Function.Module.runMain (module.js:501:10)
at startup (node.js:129:16)
at node.js:814:3
There is definitely an app.js there as evidenced in my putty session
[ec2-user#ip-172-31-12-80 dist]$ pwd
/var/app/current/dist
[ec2-user#ip-172-31-12-80 dist]$ ls -l
total 20
-rw-r--r-- 1 nodejs nodejs 3298 Apr 14 11:43 app.js
drwxr-xr-x 27 nodejs nodejs 4096 Apr 14 11:43 node_modules
-rw-r--r-- 1 nodejs nodejs 858 Apr 14 11:43 package.json
drwxr-xr-x 3 nodejs nodejs 4096 Apr 14 11:43 public
drwxr-xr-x 2 nodejs nodejs 4096 Apr 14 11:43 routes
Anyone know what could be going wrong?
Thanks in advance,
Chris

Related

Cannot find module 'http-simple-proxy' - although everything is set correctly

I installed http-simple-proxy globally. I even have it as command in the shell. Then - I created a small JS file with the content from the README (the first section, Installation and basic usage), but when I run it with node {name-of-JS-file} - and it failed with:
$ node {name-of-JS-file}
internal/modules/cjs/loader.js:883
throw err;
^
Error: Cannot find module 'http-simple-proxy'
Require stack:
- {name-of-JS-file}
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:880:15)
at Function.Module._load (internal/modules/cjs/loader.js:725:27)
at Module.require (internal/modules/cjs/loader.js:952:19)
at require (internal/modules/cjs/helpers.js:88:18)
at Object.<anonymous> ({name-of-JS-file:3:23)
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 Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12) {
code: 'MODULE_NOT_FOUND',
requireStack: [ '{name-of-JS-file' ]
}
I have setup the necessary stuff correctly:
$ node -v
v14.16.0
$ npm -v
7.8.0
$ echo $NODE_PATH
/home/petar/.npm-packages
$ ls -la $NODE_PATH
total 24
drwxr-xr-x 6 petar users 4096 Oct 26 15:19 .
drwxr-xr-x 62 petar users 4096 Apr 21 21:22 ..
drwxr-xr-x 2 petar users 4096 Apr 21 20:56 bin
drwxr-xr-x 2 petar users 4096 Oct 19 2020 etc
drwxr-xr-x 3 petar users 4096 Oct 15 2020 lib
drwxr-xr-x 3 petar users 4096 Oct 26 15:19 share
$ which http-simple-proxy
/home/petar/.npm-packages/bin/http-simple-proxy
$ http-simple-proxy
usage: http-simple-proxy [options]
Starts a http-simple-proxy server using the specified command-line options
options:
--version
--config CONFIGFILE Configuration file (YAML or JSON)
--configloader JS-FILE Provide js file as config loader
--configloader-test Test config configloader by printing out its output
--watch Watch config for changes and automatically reload with zero downtime
--silent Silence the log output
--user USER User to drop privileges to once server socket is bound
--group GROUP Group to drop privileges to once server socket is bound
--show-rules Show all rules upon every config load
-h, --help You're staring at it
See https://github.com/gusnips/http-simple-proxy for further info
Any idea what the issue might be?
I installed http-simple-proxy globally.
Globally installed packages are not available for import/require from Node.js programs. You need to install it locally, or at least in the path to your project. Note that the README say to npm install --save http-simple-proxy and does not say to install it globally. Install it globally to get the executable available to your shell, but not to use in a Node.js program itself.

kubernetes giving error,but code works

every time when deploying this images getting this error`
module.js:540
throw err;
^
Error: Cannot find module '/app/index.js'
at Function.Module._resolveFilename (module.js:538:15)
at Function.Module._load (module.js:468:25)
at Function.Module.runMain (module.js:684:10)
at startup (bootstrap_node.js:187:16)
at bootstrap_node.js:608:3
but code works on pc,I hadn't get error for other deployments they was done this way
dockerfile`
FROM node:8.9
ENV port 3000
WORKDIR /app
COPY package.json /app
RUN npm install
COPY . /app
CMD ["sh", "-c", "node index.js --port=${port}"]
yaml `
output of RUN ls -la after COPY ./app
Step 7/8 : RUN ls -la
---> Running in 9e24667abd49
total 76
drwxr-xr-x 9 root root 4096 Jun 21 07:14 .
drwxr-xr-x 57 root root 4096 Jun 21 07:14 ..
-rw-rw-r-- 1 root root 30 May 31 09:00 .dockerignore
-rw-rw-r-- 1 root root 151 Jun 21 07:14 Dockerfile
-rw-rw-r-- 1 root root 556 Jun 20 15:16 api.yaml
drwxrwxr-x 2 root root 4096 May 23 09:03 controllers
-rw-rw-r-- 1 root root 446 Jun 20 15:18 index.js
drwxrwxr-x 3 root root 4096 May 15 11:27 insert
drwxrwxr-x 3 root root 4096 May 15 11:27 modules
drwxr-xr-x 69 root root 4096 Jun 20 15:07 node_modules
-rw-r--r-- 1 root root 20404 Jun 20 15:07 package-lock.json
-rw-rw-r-- 1 root root 328 May 31 09:02 package.json
drwxrwxr-x 2 root root 4096 May 15 11:27 services
drwxrwxr-x 2 root root 4096 Jun 14 14:56 settings
drwxrwxr-x 2 root root 4096 May 23 09:35 utilities
just forget this!!I've tagged the same container as new version,pushed and its works!
Answered by Grigor:
I've tagged the same container as new version,pushed and its works!

webpack unable to resolve node module in docker image

#Dockerfile
FROM node:alpine
RUN mkdir /morty
ADD . /morty/
WORKDIR /morty/
RUN yarn cache clean && yarn install
RUN ls node_modules | grep autosuggest
RUN find /morty/node_modules/react-autosuggest -ls
CMD npm run dev
This builds as expected, but as soon as I request a page from the dev server, I get an error
ERROR in ./src/components/molecules/AutoSuggest/index.js
web_1 | Module not found: Error: Can't resolve 'react-autosuggest' in '/morty/src/components/molecules/AutoSuggest'
web_1 | #
which would suggest to me that for some reason, the react-autosuggest module was not installed; however, the output of step 6 & 7 in my Dockerfile seems to invalidate that hypothesis.
Step 6/7 : RUN ls node_modules | grep autosuggest
---> Running in 0c87c4318a6f
react-autosuggest
Step 7/9 : RUN find /morty/node_modules/react-autosuggest -ls
---> Running in 498c6b9080c7
12042711 4 drwxr-xr-x 3 root root 4096 Mar 6 16:40 /morty/node_modules/react-autosuggest
12042729 4 drwxr-xr-x 3 root root 4096 Mar 6 16:40 /morty/node_modules/react-autosuggest/dist
521128 4 -rw-r--r-- 1 root root 1735 Mar 6 16:40 /morty/node_modules/react-autosuggest/dist/theme.js
12042731 4 drwxr-xr-x 2 root root 4096 Mar 6 16:40 /morty/node_modules/react-autosuggest/dist/standalone
521127 36 -rw-r--r-- 1 root root 33193 Mar 6 16:40 /morty/node_modules/react-autosuggest/dist/standalone/autosuggest.min.js
521126 112 -rw-r--r-- 1 root root 113248 Mar 6 16:40 /morty/node_modules/react-autosuggest/dist/standalone/autosuggest.js
521123 28 -rw-r--r-- 1 root root 27217 Mar 6 16:40 /morty/node_modules/react-autosuggest/dist/Autosuggest.js
521124 4 -rw-r--r-- 1 root root 65 Mar 6 16:40 /morty/node_modules/react-autosuggest/dist/index.js
521121 24 -rw-r--r-- 1 root root 24423 Mar 6 16:40 /morty/node_modules/react-autosuggest/README.md
521129 8 -rw-r--r-- 1 root root 4195 Mar 6 16:40 /morty/node_modules/react-autosuggest/package.json
521120 4 -rw-r--r-- 1 root root 1088 Mar 6 16:40 /morty/node_modules/react-autosuggest/LICENSE
package.json does contain the entry "react-autosuggest": "^9.3.4", in dependencies and the app performs as expected in its un-containerized form.
also, possibly relevant is that the base config for this project came from
the Arc project
I also faced this issue while trying to build my npm project using a container which had WORKDIR as a mounted volume. I resolved this issue by removing the mounted volume by name.
docker volume ls to list the volumes
DRIVER VOLUME NAME
local myproject_named_volume
docker volume rm -f myproject_named_volume to remove the volume
Hope this helps.

node.js: Error: Cannot find module './Etherio'

I'm in the middle of updating my node.js code (http://ushomeautomation.com/Projects/node-irrigation/sched.js , code in question is near the top of the file) and this is my first module which is installed via:
npm install --save git+https://git#github.com/linuxha/Etherio.git
The Etherio code is in development too. This works:
var Etherio = require('/home/njc/dev/irrigation/irrnode/node_modules/Etherio');
but this doesn't:
var Etherio = require('./Etherio');
And what I mean by works is that the code runs and the lights lite up on the etherio board (which is what my module talks to).
~/dev/irrigation/irr-sched$ node ./sched.js
module.js:329
throw err;
^
Error: Cannot find module './Etherio'
at Function.Module._resolveFilename (module.js:327:15)
at Function.Module._load (module.js:278:25)
at Module.require (module.js:355:17)
at require (internal/module.js:13:17)
at Object.<anonymous> (/home/njc/dev/irrigation/irr-sched/sched.js:70:15)
at Module._compile (module.js:399:26)
at Object.Module._extensions..js (module.js:406:10)
at Module.load (module.js:345:32)
at Function.Module._load (module.js:302:12)
at Function.Module.runMain (module.js:431:10)
~/dev/irrigation/irr-sched$ pwd
/home/njc/dev/irrigation/irr-sched
~/dev/irrigation/irr-sched$ ls -la node_modules/Etherio/
total 24
drwxr-xr-x 2 njc njc 4096 Nov 28 19:33 .
drwxr-xr-x 59 njc njc 4096 Nov 28 19:33 ..
-rw-r--r-- 1 njc njc 4183 Nov 28 19:33 Etherio.js
-rw-r--r-- 1 njc njc 2317 Nov 28 19:33 package.json
-rw-r--r-- 1 njc njc 90 Nov 28 19:33 README.md
Am I missing something obvious?
Linux Debian (3.16.36-1+deb8u1 x86_64)
npm (3.3.12)
node (v5.2.0)
Making my comment into an answer since it solved the issue:
This appears to be just a path issue.
I don't quite understand your directory structure, but require('./Etherio'); looks for the module in the same directory as the module whose code is currently running and it looks ONLY in that directory (it does not look in the node_modules directory below.
If Etherio is in node_modules below the current module directory, then just use require('Etherio');

Easyrtc gives socket.io.js file issue for the html of the site

The same question is available on easyrtc forum
https://easyrtc.com/forums/viewthread/167/
I was trying to implement the demo provided here : https://demo.easyrtc.com/demos/demo_audio_video_simple.html
Following steps as given in the below link
https://easyrtc.com/docs/guides/easyrtc_server_install.php
—-
Install Node.js
curl -sL https://deb.nodesource.com/setup | sudo bash -
sudo apt-get install -y nodejs
—-
I am at logged in as root user
root#pbx:/var/www/html#
I did not get any erorr while running above commands
After running the above commands , I went to the second step
——-
2. Create folder hold the EasyRTC application
ex: sudo mkdir /var/nodes
ex: sudo mkdir /var/nodes/easyrtc
—-
I created a folder /var/nodes/easyrtc as given in example
Should I create instead on /var/www/html (where my domain is pointed to)
—-
3. Security Considerations (not going into specifics)
Create user for node.js (or use existing web user)
chown the nodes folder to be owned by this user
ensure the node is run as that user.
—-
Skipping above step since I am already logged in as root.
Please point out how I could verify the three things mentioned above.
———
Download files from the server_example(https://github.com/priologic/easyrtc/tree/master/server_example) folder into your EasyRTC application folder.
OR download and extract this .zip
—-
Does ‘EasyRTC application folder’ mentioned above indicate /var/nodes/easyrtc ?
https://github.com/priologic/easyrtc/tree/master/server_example
root#PBXRecptionist2:/var/nodes/easyrtc# ls
easyrtc-master master.zip package.json README.md server.js static
After downloading the files I get the above in the easyrtc folder
—
Change to the easyrtc folder and then install node modules locally
cd /var/nodes/easyrtc
sudo npm install
—
following the other instructuion
It added node_modules folder with modules as given below
root#PBXRecptionist2:/var/nodes/easyrtc/node_modules# ls
easyrtc express socket.io
—-
Running EasyRTC Server
From Console
Open your console on the server.
In Windows you can use the provided Node.js console program located in the Start Menu.
Navigate to your EasyRTC application folder
Run the server using the node command.
node server.js
—
What does “Open your console on the server.
” mean?
I am logged in via ssh
should I type command “node ” which opens a node console ??
Does “Navigate to your EasyRTC application folder” this mean moving to /var/nodes/easyrtc ?
When I do this “Run the server using the node command.” ,
node.js on /var/nodes/easyrtc
I get the following error
root#PBXRecptionist2:/var/nodes/easyrtc# node server.js
module.js:340
throw err;
^
Error: Cannot find module ‘../’
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object. (/var/nodes/easyrtc/server.js:5:15)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Function.Module.runMain (module.js:497:10)
and if I do it
root#PBXRecptionist2:/var/nodes/easyrtc# node
node server.js
...
I dont get anything
can anybody point where I am going wrong
Also I get an error that” Your HTML has not included the socket.io.js library”
I am unsure how can I locate the socket.io.js library
My index.html for which I get the above error is
ABCTELECOMMUNICATION: Simple Audio and Video Chat
[removed][removed]
[removed][removed]
[removed][removed]
Not yet connected…
Connected users:
<div id=“otherClients”></div>
</div>
<div id=“videos”>
<video autoplay=“autoplay” class=“easyrtcMirror” id=“selfVideo” muted=“muted” volume=“0” ></video>
<div >
<video autoplay=“autoplay” id=“callerVideo”></video>
</div>
<!—each caller video needs to be in it"s own div so it"s close button can be positioned correctly—>
</div>
</div>
files in the same directory as on the index.html are
drwxr-xr-x 7 root root 4.0K Mar 22 09:14 node_modules
-rw-r—r—1 root root 603 Mar 22 09:08 server.js
-rw-r—r—1 root root 1.2K Mar 22 08:49 index.html
drwxr-xr-x 2 root root 4.0K Mar 22 08:44 easyrtc
-rw-r—r—1 root root 1.2K Mar 21 15:23 index.html~
-rw-r—r—1 root root 170 Mar 20 12:02 socket.io.zip
-rw-r—r—1 root root 1.4K Mar 17 09:50 server.crt
-rw-r—r—1 root root 1.2K Mar 17 09:47 server.csr
-rw-r—r—1 root root 1.7K Mar 17 09:31 server.key
-rw-r—r—1 root root 1.8K Mar 17 09:30 server.key.secure
drwxr-xr-x 2 root root 4.0K Feb 21 10:15 js
drwxr-xr-x 2 root root 4.0K Feb 21 10:00 easyrtc-master
-rw-r—r—1 root root 695K Feb 21 10:00 master.zip
drwxr-xr-x 3 root root 4.0K Aug 24 2015 api
drwxr-xr-x 5 root root 4.0K Aug 24 2015 demos
drwxr-xr-x 3 root root 4.0K Aug 24 2015 dev
drwxr-xr-x 4 root root 4.0K Aug 24 2015 docs
-rw-r—r—1 root root 100 Aug 24 2015 index.js
drwxr-xr-x 2 root root 4.0K Aug 24 2015 lib
-rw-r—r—1 root root 1.4K Aug 24 2015 LICENSE
-rw-r—r—1 root root 932 Aug 24 2015 package.json
-rw-r—r—1 root root 5.7K Aug 24 2015 README.md
drwxr-xr-x 3 root root 4.0K Aug 24 2015 server_example
Can someone help me debug and make the easyrtc work?

Resources