Vue | How to change port number to 80 for web? - javascript

So I'm trying to deploy my vue app and for testing I want to switch my port 80 so I can see links without the :8080 extension. When I do this I get a fatal error
> node build/dev-server.js
> Starting dev server...
events.js:183
throw er; // Unhandled 'error' event
^
Error: listen EACCES 0.0.0.0:80
at Server.setupListenHandle [as _listen2] (net.js:1343:19)
at listenInCluster (net.js:1401:12)
at Server.listen (net.js:1485:7)
at Function.listen (/Users/Maceto/Desktop/sts/StsSnag/client/node_modules/express/lib/application.js:618:24)
at Object.<anonymous> (/Users/Maceto/Desktop/sts/StsSnag/client/build/dev-server.js:85:18)
at Module._compile (module.js:653:30)
at Object.Module._extensions..js (module.js:664:10)
at Module.load (module.js:566:32)
at tryModuleLoad (module.js:506:12)
at Function.Module._load (module.js:498:3)
at Function.Module.runMain (module.js:694:10)
at startup (bootstrap_node.js:204:16)
at bootstrap_node.js:625:3
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! client#1.0.0 start: `node build/dev-server.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the client#1.0.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/Maceto/.npm/_logs/2019-02-28T21_07_27_188Z-debug.log
I'm not sure what I'm doing wrong I changed the port in the config file but I get this. This also only happens on port 80.

You have to either do
sudo node build/dev-server.js
or
sudo setcap 'cap_net_bind_service=+ep' /path/to/nodejs
and then you'll be able to do it without sudo

Related

`webpack serve` fails with "Error: Cannot find module '../../lib/webpack-cli'"

I'm trying to set up a project using webpack. When I try to serve it using webpack I get this:
root#d690f9010746:~/chat-webapp# npm run serve
> chat-webapp#1.0.0 serve /root/chat-webapp
> webpack serve --config webpack.config.js
internal/modules/cjs/loader.js:638
throw err;
^
Error: Cannot find module '../../lib/webpack-cli'
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:692:17)
at require (/root/chat-webapp/node_modules/v8-compile-cache/v8-compile-cache.js:161:20)
at Object.<anonymous> (/root/chat-webapp/node_modules/#webpack-cli/serve/index.js:4:20)
at Module._compile (/root/chat-webapp/node_modules/v8-compile-cache/v8-compile-cache.js:192:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:789: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)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! chat-webapp#1.0.0 serve: `webpack serve --config webpack.config.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the chat-webapp#1.0.0 serve script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2020-05-31T19_42_42_752Z-debug.log
The line /root/chat-webapp/node_modules/#webpack-cli/serve/index.js:4 (mentioned in the stacktrace) says: const WebpackCLI = require("../../lib/webpack-cli");. But I don't have the file /root/chat-webapp/node_modules/lib/webpack-cli - and even if I did, it's not in the #webpack-cli/serve repo, and the repo shouldn't be making assumptions about the locations of files it doesn't control.
And yet I can't find anyone or stackoverflow or anywhere else who's getting an error on the same relative path. So what am I missing? I've installed all the npm repos locally, which is a bit non-standard - could it be something to do with that?

The application can't find the module dist

I have a NodeJs Application and I try to start it in terminal using npm run start:prod. I receive the error:
Error: Cannot find module '../dist'
at Function.Module._resolveFilename (module.js:543:15)
at Function.Module._load (module.js:470:25)
at Module.require (module.js:593:17)
at require (internal/module.js:11:18)
at Object.<anonymous>
at Module._compile (module.js:649:30)
at Object.Module._extensions..js (module.js:660:10)
at Module.load (module.js:561:32)
at tryModuleLoad (module.js:501:12)
at Function.Module._load (module.js:493:3)
npm ERR! errno 1
npm ERR! mern-starter#2.0.0 start:prod: `cross-env NODE_ENV=production node app.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the mern-starter#2.0.0 start:prod script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
And there is indeed no dist folder or file. What is it usually used for?
Do you know how it can be solved?

Error: ENOENT: no such file or directory, `node src/index.js`

I am working in node Js. When im trying to load a file, with this lines:
key: fs.readFileSync('./localCerts/local.dev.key'),
cert: fs.readFileSync('./localCerts/local.dev.crt'),
This is error appeards when I try to rub application:
bou-frontend#0.0.1 start /Users/nikolatrajkovic/Desktop/projects/bou-frontend/bou-frontend
node src/index.js
fs.js:114
throw err;
^
Error: ENOENT: no such file or directory, open
'/Users/nikolatrajkovic/Desktop/projects/bou-frontend/bou-frontend/build/index.html'
at Object.openSync (fs.js:438:3)
at readFileSync (fs.js:343:35)
at Object. (/Users/nikolatrajkovic/Desktop/projects/bou-frontend/bou-frontend/src/ssr.js:34:22)
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)
at Module.require (internal/modules/cjs/loader.js:637:17)
at require (internal/modules/cjs/helpers.js:22:18) npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! bou-frontend#0.0.1 start: node
src/index.js npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the
bou-frontend#0.0.1 start script. npm ERR! This is probably not a
problem with npm. There is likely additional logging output above.
PACKAGE.json file:
scripts": {
"start": "node src/index.js",
}
Any advice or help is welcome.

Node Js Error Module.js 549

While starting my application, I get this error. I have already checked and seen that the required module is well installed, and also gave it global access.
Hussains-MacBook-Pro:NodeRest-Shop Hussain$ npm start
> noderest-shop#1.0.0 start /Users/Hussain/Desktop/Development/Web/NodeRest-Shop
> nodemon server.js
module.js:549
throw err;
^
Error: Cannot find module 'binary-extensions'
at Function.Module._resolveFilename (module.js:547:15)
at Function.Module._load (module.js:474:25)
at Module.require (module.js:596:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (/Users/Hussain/Desktop/Development/Web/NodeRest-Shop/node_modules/is-binary-path/inde
x.js:3:24)
at Module._compile (module.js:652:30)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! noderest-shop#1.0.0 start: `nodemon server.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the noderest-shop#1.0.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/Hussain/.npm/_logs/2018-06-25T05_23_59_594Z-debug.log
You're missing the binary-extensions module, as seen in your log:
Error: Cannot find module 'binary-extensions'
It could be that you're missing some dependencies or forgot to include it.
You can install it using npm:
npm install binary-extensions
And include binaryExtensions in your project:
const binaryExtensions = require('binary-extensions');
I fixed this issue by running:
npm i npm#latest -g
Check your app.js file your index route should be
app.use(require('./routes/')); not app.use(require('./routes/index'));

Node.js with parse.com (ParseOpenSource javascript sdk) installed - fails on AWS eb deploy

I am trying to 'eb deploy' a node.js with javascript sdk addition.
It works fine locally but every time I have tried to - eb deploy- it I get this in the logs
npm ERR! npm bugs node-express
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!
npm ERR! npm owner ls node-express
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /var/app/current/npm-debug.log
> node-express#0.0.0 start /var/app/current
> node main.js
{ [Error: ENOENT: no such file or directory, open '.env'] errno: -2, code: 'ENOENT', syscall: 'open', path: '.env' }
module.js:327
throw err;
^
Error: Cannot find module 'parse/node'
at Function.Module._resolveFilename (module.js:325:15)
at Function.Module._load (module.js:276:25)
at Module.require (module.js:353:17)
at require (internal/module.js:12:17)
at Object.<anonymous> (/var/app/current/api/common/parse.js:3:13)
at Module._compile (module.js:409:26)
at Object.Module._extensions..js (module.js:416:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Module.require (module.js:353:17)
...npm ERR! code ELIFECYCLE
npm ERR! node-express#0.0.0 start: `node main.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the node-express#0.0.0 start script 'node main.js'.
npm ERR! This is most likely a problem with the node-express package,
I have repeatedly tried
npm install express --save
and yes I have also run npm install parse (it all works fine locally).
To no avail. Why would it all work like a charm locally but not on AWS EB ?
-Thanks for any clues.
Not sure if this will help someone. Ultimately I solved this by
'npm install moduleName --save' on all of my modules. One by one.
Still not sure why the site worked locally ?
-best of luck.

Categories

Resources