Make heroku read specific file insteade of node_modules - node.js

I wonder is there any way to make Heroku to read specific file instead of node modules. I'v made scraper with puppeteer but there is an error, I have found why thet error is appearse and I'v changed file in puppeteer files(in node_modules) so it works on my machine, but how can i make this changes on heroku if i dont have access to node_modules on heroku. So i wonder is there any way to make heroku to read specific file instead of reading this file from node_modules? Thanks.

Related

DiscordJS & Heroku: Error: Cannot find module '../Modal'

So this is lately one of the most popular issues in discord.js community. Appears after updating to d.js v13.7.0 and higher. While it works perfectly on a PC or etc., it fails to run on Heroku hosting with the following message:
Error: Cannot find module '../Modal'
This is clear that the issue is on Heroku's side, because Modal file can be found in discord.js dependency folder in node_modules.
I have NodeJS v18.3.0, have tried reinstalling discord.js with multiple methods, nothing helped.
I wasn't able to find any solutions to the problem, have anyone over here found the solution?
Im pretty sure that you didn't create a file called .gitignore because it shows that your problem is on the folders '../Modal', Before deploying it to heroku, you should ignore the 2 files on your project.
node_modules
.env (if you have)
To remove these 2 on your deploying, create a file on your main folder named .gitignore and right down the following:
node_modules
.env

Problems with getting started with node.js and puppeteer

I am quite new to programming and today decided to attempt and create a node.js and puppeteer project with the purpose of scraping website into a .txt file. I ran into issues straight away since for the most part I have no idea what I'm doing. After installing node.js and puppeteer, I was guided by some videos and articles I found to create my first project. In the command prompt using mkdir and later cd I was able to create and access the new directory, but I started running into problems with npm init. It only places the file package.json in the repository, but there isn't a package-lock or node_modules file anywhere. No idea what they do but thought this was a problem. When I open cmd and try to run the app by typing node app.js it returns Error: Cannot find module 'C:\Users\emili\app.js' along with some other gobble. What should I do, to be able to run the simple application I wrote?
It seems that you are missing some key knowledge on how NodeJS works, but in order to fix your issue (for now), you will need to take a few steps.
First, in your working directory (where the package.json is), you'll need to install your modules.
Run npm install puppeteer. This will do two things, create the node_modules folder and create the package-lock.json file.
Create a file named app.js (either manually or by running the command touch app.js) in your working directory, and put the following content inside of it:
console.log('Hello, World!');
Save the changes to app.js and then run node app.js in your terminal. You should see Hello, World! output to the terminal.
The reason npm install puppeteer created the node_modules folder and the package-lock.json file is because they weren't needed beforehand.
When you run npm install PACKAGE_NAME, you're installing a module (otherwise known as a package), thus it creates the node_modules folder so that it will have a place to put the module so that your code can access it. It also creates the package-lock.json file, which is used to track the module versions inside of your project.
With this information, I request you go back to the tutorial you were originally following and try going through it again and attempting to understand each of the core concepts before writing any real code.

showing Failed to find package.json. Node.js may have issues starting. Verify package.json is valid or place code in a file named server.js or app.js

showing Failed to find package.json. Node.js may have issues starting. Verify package.json is valid or place code in a file named server.js or app.js. when deploying node js file in AWS ELASTIC BEANSTALK cloud, what are the reasons to showing that message and how to resolve that issue.
There can be multiple reasons. Can you please check the logs generated in Beanstalk.
The way how you have zipped the package can cause an error. Make sure, you go inside the source directory and zip the files and folders, instead of zipping the single folder itself.
Secondly, the way how you have created the app.js or index.js.
The Nodejs versions can be another reason.
The below approach worked for me 2 years back when I started using Beanstalk for my Nodejs applications.
Also, I would recommend deploying a sample nodejs application from this link and progressing from there. https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/nodejs-getstarted.html

Getting 'Cannot GET /' when trying to connect to localhost:5000 Firebase

I am trying to get my localhost server on Firebase to work but I am continuing to get the following message in the browser 'Cannot GET /'. I took a look in the console and all it says is 'http://localhost:5000/ 404 (Not Found)'.
I have tried re-running the server using 'firebase serve' and that doesn't help.
I ran 'firebase init' again and that didn't help either.
I re-installed the firebase tools by running 'npm install -g firebase-tools' and then running firebase serve again and still nothing.
Not sure whats going on because it was initially working. I installed some grunt plugins and moved my index.html file under an html folder although I still have an index.html file under the public folder it still says 'Cannot GET /'
I have also tried in different browsers restarting them etc.
I am using a Mac OS X El Capitan.
Let me know if you need any more info. Thanks in advance
I had this issue running firebase serve from within the scripts directory in the "Friendly Chat" tutorial. Starting the server from the parent directory got it working again as expected.
if this will help someone save time.. a possibility: it could be that the build step did not complete, this was my case, and the build/... directory had no index.html
I had the same issue when was trying to serve an Angular application with the firebase command.
Firstly, you should see the firebase.json file.
It should contain the "public" value, like:
{
"public":"dist/ProjectName"
...
}
But the dist folder will be auto created only after you build the Angular project:
ng build --prod
After you can do the:
firebase serve
Hope it will be helpful for beginners.
Ok so got this working but pretty much had to start from scratch again. I deleted the public folder and just moved my html, css, js, and node-module folders out of my project directory and then re-installed firebase-tools and ran the 'firebase init' command and then restarted the localhost server and everything started working again. After which point I moved back all my previous folders and things are working as before.
Not a 100% sure how the issue happened but at one point I did delete my index.html file and then put it back in later on as I was testing something. At which point I feel the issue started. I will try to test this scenario in a test project but I guess for the time being don't delete your index.html file just modify the existing one. Thanks all.
The error message shows up if you run 'firebase serve' within the project folder.
Navigate to the parent folder (up one level) using 'cd ..' and start the server from there.
Please check if content of your website is present in folder
"hosting": {
"public": "<folder with your website files>",
from your config "firebase.json"
If you like me, before overthinking the problem, make sure you provided the correct URL to index.html.
In my case, I didn't take into account different structure of my directory. You should provide the path to index.html relative to the root directory of your firebase project. For example, in my case, the correct URL was http://localhost:5000/button-component/public/

Heroku detects Clojure app as Node.js one

Heroku detects app type by presence of files like package.json or project.clj.
I am trying to build Clojure app, so I have project.clj in my root directory. But I also use some node.js tools, so I have package.json too.
Is there a way to tell Heroku what kind of app I build, but keep package.json?
Create a .slugignore file with the contents package.json and Heroku will not see that file, even though it will be in your git archive.

Resources