How can I open my node.js program in chrome? - VS Code - javascript

I'm new to node.js, and VS Code. I'm watching this tutorial, and the issue is that in the video, he runs his server. I can do this fine, but, when he opens his browser and types http://localhost:8888, he can connect to the server like he is a client. When I do this, the program Emit(I think that is what its called) opens and has an error - Error: ENOENT: no such file or directory, open 'h:\Microsoft VS Code\bin\index.html' at Error (native). In the beginning of the tutorial, he went to edit configurations and entered the local host url into some text box and changed other settings. Although, he is using IntelliJ, and I'm using VS Code. How can I make it so I can enter the url and run as a client.
[EDIT]: When I try to start without debugging, I get the options select enviornment - Chrome or Node.js. Also, I went to the terminal and typed node app(file name is App.js), and I get the error in the terminal - module.js: 471. throw err. Error: cannot find module at C:Users\Name\App
Thank you.

Related

React native fetch() causing unknown error Error: ENOENT: no such file or directory, open 'C:\root\react-native\ReactAndroid\hermes-engine.cxx\Release

I have made a simple REST API, and I have a react native application where I am trying to call the API with fetch. The server is running on the same computer as the react native application, in my fetch call I used 'fetch('http://10.0.2.2:3000/Users)' which from what I know is the correct way to call it. When I run my react-native application to test if the connection works, I get the following error:
Error: ENOENT: no such file or directory, open 'C:\root\react-native\ReactAndroid\hermes-engine.cxx\Release\21w5t5f5\x86_64\lib\InternalBytecode\InternalBytecode.js'
at Object.openSync (node:fs:584:3)
at Object.readFileSync (node:fs:452:35)
at getCodeFrame (C:\Users\brayd\projects\startscreentest\node_modules\metro\src\Server.js:1004:18)
at Server._symbolicate (C:\Users\brayd\projects\startscreentest\node_modules\metro\src\Server.js:1073:22)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async Server._processRequest (C:\Users\brayd\projects\startscreentest\node_modules\metro\src\Server.js:437:7) {
errno: -4058,
syscall: 'open',
code: 'ENOENT',
path: 'C:\root\react-native\ReactAndroid\hermes-engine.cxx\Release\21w5t5f5\x86_64\lib\InternalBytecode\InternalBytecode.js'
Has anyone got this error before and know of a a solution? Would really appreciate some help with this, I have been tried almost everything I can think of and at this point I am lost as to what I should do.
I have never seen this error before, I have looked online to see if anyone has posted a solution and found nothing, I have no idea how to solve this error, I have been debugging for hours, and have tried countless things including changing the fetch url, making a new application, etc. I know the api works because I have tested all the routes with curl, I know the fetch statements work because I created a js project and tested the fetch statements. For some reason, its just not working on my react-native application, its either giving me the above error, or if I change the url to something else like 'fetch('http://localhost:3000/Users)' it just gives me 'network connection error'.
You have to create a wamp or nginx server on your computer. Then your API project starts on a server. After that, you can access your pc IP address. Actually, your react native simulator doesn't work on your pc. So you can't access the directly pc IP address.

javascript error when trying to open notarized .pkg

Running Mac OS 12.3.1.
I have an .app I wrote using Python and Pyinstaller and I wish to create a .pkg from it.
First, I code-signed the app:
codesign -f -o runtime -v --deep --timestamp --entitlements
/Users/fishbacp/Desktop/entitlements.plist -s "Developer ID Application: My Name
(XXXXXX7RBW)" /Users/fishbacp/Desktop/my_app.app
I then used
-spctl -a -vv '/Users/fishbacp/Desktop/my_app.app'
which was accepted. To test things at this stage, I had the .app notarized and opened it on both my machine and a different one. Everything worked fine.
From there I build a signed product:
productbuild –timestamp --sign 'Developer ID Installer: My Name (XXXXXX7RBW)' --
component /Users/fishbacp/Desktop/my_app.app /Applications
/Users/fishbacp/Desktop/my_package.pkg
Check the package is signed:
pkgutil --check-signature /Users/fishbacp/Desktop/my_package.pkg
which worked.
Then I submitted my_package.pkg for notarization. It was successfully notarized, and the log file yielded no warnings.
However, when I double click on the my_package.pkg a pop-up window states the package could not be read due to a javascript error.
I looked into my computer's installer log, which stated
Failed to load specified background image
It also stated
IFJS: *** exception: SyntaxError: Unexpected identifier 'Connectivity'. Expected an
opening '(' before a function's parameter list.
For reference, the actual name of my .app is EEG Connectivity Explorer.app.
Observations:
The IFJS exception: SyntaxError seems very strange and vague to me. In light of the fact the .app was notarized and opened, I can't see where it's coming from.
Using a very simple test .app, I found the installer works.
Could the background image message in the installer log suggest I need to create a separate Distribution.xml by any chance? (I have no experience with creating one and would have to look into that should that be the case.)
I'm really at a loss for what to try next.

Windows Script Host Error 800A03EA on Express.js code

I am learning JavaScript development and the book I'm following (JavaScript Everywhere) tells me run this code:
const express = require('express');
const app = express();
app.get('/', (req, res) => res.send('Hello World'));
app.listen(4000, () => console.log('Listening on port 4000!'));
I understand what this code is supposed to do but when I try to run it using src/index.js in the terminal, it always gives me this error:
Syntax Error 800A03EA Microsoft JScript compilation error
I have tried all fixes I found on the internet but I'm guessing this has something to do with the fact that this isn't regular JS syntax, it's Express JS and somehow Express JS is not enabled? I've checked the basics including:
node --version (returns v12.14.0)
npm --version (returns 6.13.4)
npm install express --save just in case there was some problem with ExpressJS API
Windows 10 Laptop, using VSCode. Please ask for any information you need.
Run it using node src/index.js.
By using just src/index.js you are using the default handler for JS files on Windows which is Windows Script Host (and not Node.js).
The solution apply for those who are facing Windows script Error code like 800A03EA. For those, who are unable to open js file and facing error like Windows Script Host.
I was stuck with the same problem for couple of days while working on react.
We have three methods of solving this problem:
Method 1:
Check your computer for viruses and remove them using various method like download MSERT.exe from Microsoft.
Method 2:
Open command prompt as administrator and type following 2 commands:
regsvr32 jscript.dll and press ENTER.
regsvr32 vbscript.dll and press ENTER.
Method 3:
Type internet option on search bar and select it.
Open advance gtab from it and go to security section.
Make sure all of the below ones are selected:
Use SSL 3.0
Use TLS 1.0
Use TLS 1.1
Use TLS 1.2
Method 4:
The workaround that must work 100% but as you know it might be helpful for all, as it only open file do not confuse read the following lines
So simply left click on file and edit and open it.
It will open in notepad and now from here you can transfer your data or use it.😁
Thanks me later for this detail answer. Now just rock the world!!!!!
Check if your file name isn't "Node.js", just try to rename it in like "randomname.js"

Can't connect to MongoDB server (no error and no messages in the console)

I installed MongoDB on Windows, made a data folder in C: directory and made a db folder inside that data folder, but mongod.exe doesn't want to run. The weirdest thing is that it doesn't give me an error or any message, it just skips to the next line like nothing happened.
Here is a screenshot of the console:
Also when I try to connect the route of mongo.exe to the PhpStorm's Mongo Plugin, PhpStorm doesn't recognize
"C:\Program Files\MongoDB\Server\3.4\bin\mongo.exe" as the path to Mongo Shell.
I installed MongoDB the same way on my other computer that uses Windows 10 and it worked, but on this one that uses Windows 7 it doesn't work.

Image and js is not geting displayed from apache tomcat

I have facing strange problem. I have deployed images and js file in Apache Tomcat directrory but it is not showing on page and a warning is coming up:
Resource interpreted as Image but transferred with MIME type text/html: "http://localhost:8084/webApp/img/access.jpg".
Earlier it was working fine but now jquery is also not working and the following error is coming up:
Uncaught ReferenceError: jQuery is not defined
Earlier this error message was appearing in Firefox but Chrome was working fine. But now it is showing the error in Chrome as well.
I have also tried to use the absolute path but no success.
<script src="/webApp/jquery-1.7.2.min.js"></script>
<img src="http://localhost:8084/webApp/img/access.jpg"/>
If you are using tomcat, you should locate the resources at $CATALINA_HOME/webapps/ROOT folder. From there, you might have access to the files.
You can check the access permissions from terminal. If you use unix / linux, locate to the folder:
cd $CATALINA_HOME/webapps/ROOT
And execute the command:
ls -la
This means it can be accessed by everyone, so should be available to everyone accessing to the server by browser
drwxr-x**r-x#** 22 user staff 704 11 jun 01:25 .
You could also try changing the permisions, but your server would be unsure:
sudo chmod a+rx webApp/img/access.jpg
Or go to the webApp folder via cd and execute
sudo chmod -R a+rx .
Deppending on your preferences (the last one means giving permission to all resources on webApp folder, what means givving access to all your projects in server, quite unsure...).
Hope it helps somebody.

Categories

Resources