NODE Js, local host, error "throw err" - javascript

I am using IBM Bluemix to make a web service for a school project.
I am having trouble running my app in the local host.
Throw err
Error: Cannot find module 'body-parser'
I can't figure out what is wrong.
Here is a print of the error screen I get when running it.

From what you are saying I assume that your application is running fine on Bluemix. Use the CLI of your machine to navigate into the application folder (where the package.json is placed) and run
npm install
it will download all the dependencies listed in the package.json in the node_modules folder inside your application root folder.
Doing this your application will have all the libraries it needs to run.

Related

A file called pty.node.js is missing after installing "node-pty" in a electron-forge project. How can I install node-pty in Linux

After installing node-pty (an external module used to create pseudo terminals using node js) in a boilerplate electron-forge project; I found it throwing an error that some core module of node-pty is importing another module which nodejs is failing to find.
After some research I discovered that entry point of node-pty is src/index.js, which imports another module called src/unixTerminal.js (this file is imported if the system is running on linux platform and my PC is running on Ubuntu 20.04) and that module tries to import build/Releases/pty.node.js (unixTerminal.js calls many functions imported from pty.node.js, so this package cannot be ommitted) but as a matter of fact build/Releases/pty.node.js is missing and completely absent in the node_modules/node-pty folder of my project where I had installed node-pty
Why does this happen? Is this any fault of myself in installing node-pty, I had installed it directly using npm i command? If a vital file of a module is missing how can it work? Please tell me how can I use node-pty on Linux and why build/Releases/pty.node.js is missing in node-pty's directory?
Since you're using Electron Forge (a crucial detail omitted from the original post), according to this issue I found by googling "node-pty electron forge" you'll need to configure the Electron packager to unpack the pty.node file:
asar: {
unpack: '**/node_modules/node-pty/build/Release/*'
},

npm run build cannot access in localhost

I want to test my react/ node.js web app with a production build. I already run npm run build at the app directory and created build folder.
I was unable to run the application using localhost:8080 (server port).
Are there any ways to double check if the application is actually running in that port or access production-ready application?
PS. I used serve to host the application but it posts error 404: The requested path could not be found
Thank you for your help.
Every SPA application has its own package.json file. Inside you have to see the script section:
Normally after you run nm run build you have a compiled version of your code.
At this point, you have a see the dist folder.
After this, you can either run npm run start and you have to see
(this option is not suitable for SSR frameworks like NUXT or NEXT)
or if you don't have that option install an npm package that renders your compiled code by doing the following:
npm install -g serve
serve -s build
and you have to see

electron - node.js - fs.readFileSync requires admin privileges when electron is built and in Program Files

I've successfully built my electron application which appears to be working substantially fine.
I use the node module fsto access files for use in my application, which is standard affair for Electron. This works exactly as expected in the development environment, and even when I build my app with the asar in C:\Users\myApp\ I can access the files from the built electron application.
However, when I've created an installer and placed the application # C:\Program Files(x86)\myApp\
fs.readFileSync
which previously worked fine both in the development verson and the built version when it was present in C:\Users\myApp\, now requires Run as Administrator Privileges to read files, else it will throw an error.
Any explanation?
Electron Version: 1.8.4
Platform: Windows 7
I believe you may want to deploy some of your application data into your %APPDATA% i.e. C:\Users\yourusername\AppData\Roaming, or in the case of electron, can deploy your files into the userData folder using app.getPath('appData') which refers you to C:\Users\yourusername\AppData\Local\your_electron_app_name or app.getPath('userData'). https://github.com/electron/electron/blob/master/docs/api/app.md#appgetpathname
In that directory, you can change the files without elevated privileges.
If you look properties of your electron application folder in your Program Files, and go to the security tab, you will noticed that that permission settings for Users is (Read & execute, List folder contents, and Read); however, administrators, have access to Full control (modify, read & execute, list folder contents, read, and write).
However, if you really need to create/edit/delete files in your Program files or ProgramData will require elevated privileges and to get around that you may want to install the npm package electron-sudo (https://www.npmjs.com/package/electron-sudo) or sudo-prompt (https://www.npmjs.com/package/sudo-prompt).

Segmentation fault on Vuejs client - Debian Server

Im working on a Vue App. I develop it on Windows and it works fine - no errors. But when I copy my project (except of the node modules) to my Debian server, install all dependencies and start it I get this error: Segmentation fault.
I found the error is based in the src folder. If I copy any file from there (except the assets folder / files) the Segmentation fault error appears but not if I copy my modified config and build files.
ps. When I copy my project to a new folder on Windows and install the dependencies it works and the Vue Client server is running.
And if I create a new vue client project on my Debian server and let it run it also works ... till the moment I copy my src folder.
Solution: I downgraded Node from 6.10 to 6.9.5
To use an older version is often the solution.
source (german): https://www.gutefrage.net/frage/segmentation-fault-error-beim-vuejs-client---debian-server?foundIn=login&randomReloadId=981505#comment-151824131

CF Push error: An application could not be detected by any available buildpack

I am using IBM Bluemix for a school project.
I have finished the code and I need to send the application to the IBM Bluemix platform.
I am using the cf toolbar and the standar methods for sending the app to the cloud (cf login, cd into the new directory, cf push etc).
Nonetheless, I get the error
Staging Failed: An application could not be detected by any available buildpack
What is causing this and how can I solve it?
Here is a print of the error screen I get when sending the app to Bluemix - With the cf logs associated with the error.
When you push your application to Bluemix your root directory is scanned in order to understand what kind of buildpack should be used. In your case you need the Node.js buildpack, which is used when in your root directory you have the package.json file. It contains all the dependencies your application needs to run and it is used by the buildpack to download all the required libraries. If your application works fine on your machine it means that you have all the required libraries in the node_modules folder. You can use the npm init command to automatically generate the package.json file for all the libraries/middleware you need. Please take a look at Npm init Docs. You can also refer to Bluemix Node.js starter application to see the default package.json.

Categories