Does nodejitsu support makefile functionality? - node.js

For example, if your package.json file contains:
"scripts": {
"start": "make start",
"test": "make test",
}
^ Will nodejitsu be able to parse and implement "make start"?

If the server.js file contains the static file path of the following directory then only the makefile functionality will work.

Nodejitsu should parse this just fine. Just be sure that you are calling node <app file>.js in your Makefile somewhere, or you change it to make start && node <app file.js>. Nodejitsu uses npm start to start your application, so the Makefile exiting without starting the app would cause the deployment to fail.

Related

NextJs vercel deployment error "routes-manifest.json" couldn't be found

My nextjs app was working properly I added some files to update my code now it is not deploying my app on vercel. gives this error
I tried googling the error but my case in unique.
This is the git repo
https://github.com/usman-174/google-calendar-frontend
These are my script tags from package.json
"scripts": {
"dev": "next",
"build": "next build",
"start": "next start",
"export": "next export",
"lint": "next lint",
"lint-fix": "next lint --fix"
},
next.config.js
module.exports = {
distDir: 'build',
}
I also ran into this error because the root directory of my app was not in the top-level directory of my Git repository, so Vercel was unable to find the .next folder.
I fixed it by going to the Vercel dashboard for my Vercel project, then -> Settings -> General and setting Root Directory to the subdirectory path to my application:
Issue was we were using 'latest' in package.json for next version. I fixed it to previous version of nextjs which is 12.3.1 for us seems to have fixed the deployment for now.
But still waiting for vercel support for best way to update nextjs version in deployment for vercel or is it some sort of bug their end.
Run npm run build (check all files in builded folder)
Create .next folder and move all files from build folder to .next
Commit your .next folder to vercel or maybe git.
In my case, make sure please if the folder within the project is called "web", the json name inside should be "web"!
In my case I had a few errors in my files
Error: `'` can be escaped with `&apos;`, `‘`, `'`, `’`. react/no-unescaped-entities
Which were being hidden in the Vercel build log because I forgot I had the following in next.config.js
eslint: {
ignoreDuringBuilds: true,
}
Which just showed me the error you have instead of the actual reason it failed.
Enabling eslint indirectly solved my issue as it led me to find the real error.
Overriding the build folder fixed my issue.

Error: Cannot find module; Typescript error in react project

I have a .js file called load_routes.js file in the node_express folder. This load_routes.js file loads all my routes for the project. I have a package.json file in which the load_routes.js is used to load the routes. So, this part was working fine, until I changed the file extension of load_routes.js file to .ts file. I started getting
Error: Cannot find module '/*****/***/****/****/****/node_express/load_routes.ts'
I have not changed the location of the files. And the node_express folder is a sibling or present at the same level as that of package.json file.
package.json file:
"scripts": {
"build": "react-scripts build && echo \"const version='$(git rev-parse HEAD)'; module.exports=version\" > ./node_express/version/release-version.js",
"eject": "react-scripts eject",
"server": "NODE_ENV=localhost PORT=**** node --max-http-header-size 81000 ./node_express/load_routes.ts",
"start": "react-scripts start",
},
Can someone help me with this. The file load_routes.ts is for sure there. The path to that file seems correct as it worked when it was a .js file. Why do I get this error? I am stuck on this for quite some time. Any help would be appreciated.
Don't specify the file extension at all. The require call will figure out the right file automatically.

How to make background API server use hot reloading in a React project?

When I save changes to my client-side code, the browser hot-reloads as expected. But when I make changes to my server code, no hot-reloading occurs. This is a problem because we want to just run 1 command (i.e. npm start) to launch our React webpack-dev-server AND our API server, and rerunning the entire npm start to manually relaunch the server after changes is slow (because it unnecessarily relaunches the React dev-server as well). Also sometimes we forget to relaunch the server code, so in reality it should just hot-reload anyway.
I've looked across the internet and surprisingly can't find any straightforward solutions. I feel like I shouldn't have to eject the entire project and go deep into the webpack configurations to get this to work.
This is what the npm start portion of my package.json looks like now:
"scripts": {
46 "start": "concurrently --kill-others \"react-scripts start\" \"node server.js\"",
...
}
Is there perhaps a way I can do "react-scripts start" with a different target or something?

Node.js applies the changes only after restart

I am very new to server side scripting. And I am using NodeJS. My Problem is that after adding some new features to the app, i.e. after changing the code, these changes will be applied only after restarting the server. Till then NodeJS behaves so as though I hadn't changed anything. So for instance if I add console.log("works") and don't restart the server, then it hasn't any effect.
I am using Nuxt.js, which is actually the Vue.js framework but with additional and very usefull features mainly for server side rendering. I didn't integrate the express.js at the beginning of the project, beacause it wasn't planned to write any server side code. So I am normally exporting express and using it, which is pretty fine for me, since I need just a couple lines of code to use the NodeJS file system.
So, as it is pretty hard to code, if I should restart the server once I changed anything, I want to ask you if there is any solution to this problem.
Use nodemon
step 1 : npm install -g nodemon <- this will install nodemon globaly in your system
step 2 : change your start script within package.json
"scripts": {
"start": "nodemon fileName" <- like this //filename is you root file which starts the app like app.js
}
step 3 : npm start
This is already build in into nuxt. You just need to run it in dev mode, not in production.
E.g. for dev with change monitoring
nuxt
For production without monitoring
nuxt start
So in this particular case the following changes to the "scripts" in package.json have solved my problem.
"scripts": {
"dev": "nodemon --watch api --exec \"nuxt\"",
"start": "nodemon nuxt",
}
The following link could also be usefull to you.
Install nodemmon in your application to allow live update npm -g install nodemon
and add the following codes inside your packages json file :
"main": "app.js",
"scripts": {
"start": "node app"
},
on your command line, just type : start

node.js Command Line Interface app on windows

I am creating a simple CLI (Command line interface) application using NodeJs, involving two files:
package.json:
index.js
I want to print "hello world" to STDOUT and it is working when running command $ node index.js
But I want to use it globally via command test. So, I put a bin entry in package.json. Then build the application using npm link .. But then when I run "test" command, Windows shows me the following error:
How can I use console.log in separate app?
Thank you!
In package.json file, you need to write the code as follows:
"name" : "test",
"version": "1.0.0",
"scripts": {
"start": "node index.js",
"build": "webpack",
},
...
...
after this, use the command npm start to run the application.
1- Create bin folder in root folder and place your index.js inside the bin.
type the shebang code on the first line of index.js:
bin/index.js
#!/usr/bin/env node
console.log("hello world");
2- Add below code into the package.json file.
"bin": {
"test": "./bin/index.js" //this is relative path
}
3-finally run this code on command line
npm link
now you run "test" in your command line, it will log "hello world"
note:pay attention to the relative path that i mentioned above.

Resources