I've created a slack bot that I want to deploy with vercel and I keep getting the error:
Error: Command "npm run build" exited with 1
when running vercel deploy.
In my package.json file I have:
"build": "next build"
which is obviously incorrect as it throws this error.
The vercel docs suggest (https://vercel.com/docs/errors#error-list/missing-build-script)
"scripts": {
"build": "[my-framework] build --output public"
so my question is, what is actually expected in here in order to make this work?
I would really appreciate some help getting the project up and running so I can use it on slack. It works locally just fine, but can't get it up and running without me starting it locally.
Here is the repo: https://github.com/Chaffexd/weds-slack-bot
The correct build script for a nextjs app is next build.
Your script currently has npm run-script build.
Which is actually the equivalent of telling it to run itself over and over, it's self referencing.
Also, as an aside, your app is not going to work on Vercel. Vercel is a serverless environment, meaning long running applications like the one you have written that is continually listening on a port (I imagine when you run it locally it hangs for input) are not supported. You should refactor your app to respond to requests, which can trigger your function.
A good way of building this app on Vercel with NextJS might be to use the NextJS API folder for your application code, and then find a free CRON runner to repeatedly hit that function endpoint every day.
Related
so I just finished building the beta version of my e-commerce application and decided to deploy to heroku from my github repository.
The first issue I ran into was not npm run build (which I did then pushed it to github) then redeployed.
Next issue was my build failed because I didn't specify the version of node. (SO i want into the package.json and typed in...)
"engines": {
"node": "16.14.2"
},
Again, redeployed I got through the build and I thought all was well. BUT I get an application error (fun) and so I go into heroku logs to see what I did wrong. Problem is I actually don't know what i did wrong. This is what the log says
I have a Django/ Vue.js app that I deployed to Heroku. It's repo is connected to Heroku so I deploy it straight from the Heroku app.
I've updated the code and run "npm run build" afterward. I run 'git add *', checkd that every files where tracked, commit them and push them to the repo.
Afterward I did a manual deploy from the Heroku app. Deployment went fine but the changes are not reflected into my deployed app.
What went wrong? Did my build failed (had no error message while building and I did get the 'build Complet' message)
I don't know where to look at. How can I be sure the changes I made are reflected into my build?
What I tried:
-deleting the build folders and "run build" again with no luck
-force my browser to clean the cache with no luck either
What I did:
I wanted to change my login/logout url redirection
My project works well with run dev command but when I try to npm start I got 404 page not found error for other pages (pages/...) except Index.js.
I tried several ways which I found from forms(gthub issues, and blogs), but nothing worked.
Any Idea? Actually why there should be difference between run dev and start? I think we should see whats wrong in our app during the dev process
the scripts from package.json
"scripts": {
"dev": "next",
"start": "next start",
"build": "next build"
},
and next.config.js
const withCSS = require("#zeit/next-css");
module.exports = withCSS({
cssModules: true,
cssLoaderOptions: {
importLoaders: 1,
localIdentName: "[local]___[hash:base64:5]"
}});
As you see I didn't change anything after installing nextJS.
I found out that if the filenames have uppercase letters on Windows, you get a 404 error.
I changed all filenames to lowercase characters and the 404 errors went away.
First, you need to understand what kind of app do you want to build.
Is it serverless? or kind of with server and what web server do u want to use (there are so many options).
For serverless app:
All you need to do for production build is next export, this function will generate static files to be served as your website. Read more here...
For app with server:
If you want to run npm run start, you need to do npm run build first.
npm run build compiles and optimizes your build for production mode.
npm run start run your web server to serve your html files.
If you have done those two steps, it means something wrong with your server files, your web server's API didn't listen to the request, therefore it doesn't redirect you to the correct page.
Before starting your application you need to build using npm run build command and then start your application.
When I build and deploy my project on our NGINX server and then call the app I get the following error:
react-dom.production.min.js:198 Error: Minified React error #185; visit https://reactjs.org/docs/error-decoder.html?invariant=185 for the full message or use the non-minified dev environment for full errors and additional helpful warnings.
at react-dom.production.min.js:13
at c (react-dom.production.min.js:14)
at nc (react-dom.production.min.js:243)
at Object.enqueueSetState (react-dom.production.min.js:130)
at e.y.setState (react.production.min.js:13)
at react-router.js:63
at t (history.js:155)
at history.js:173
at Array.forEach (<anonymous>)
at Object.notifyListeners (history.js:172)
The link in the error shows me the following explanation:
We highly recommend using the development build locally when debugging
your app since it tracks additional debug info and provides helpful
warnings about potential problems in your apps, but if you encounter
an exception while using the production build, this page will
reassemble the original text of the error.
And the error...
Maximum update depth exceeded. This can happen when a component
repeatedly calls setState inside componentWillUpdate or
componentDidUpdate. React limits the number of nested updates to
prevent infinite loops.
When I develop locally, I call the npm run-script dev which does the following:
webpack-dev-server --open --mode development
In my Jenkins job, I do this to build and deploy the application:
npm install --verbose
npm run-script build
Build is doing this: webpack --config ./webpack.config.js --mode production
Now to my problem:
The mentioned error leads to a white page and is not repeatable in my local environment. The error just occurs on the deployed app on the NGINX server.
I really don't know how to solve this issue that only occurs on the server and does not show any hints what the cause of this problem might be, but only tells me to fix this issue locally where the problem is not even present.
Does anyone have an idea what I can do to find out the cause of this, or even know the reason for the bug itself?
I am deploying a Vue client using Vue-cli 3, which uses Webpack
(I can start the client by calling "yarn dev --open")
I am also writing a server with an API for the client
(I can start the server by calling "node server/server.js")
Is there a way to start both the client and the server with one command?
I was thinking that I should add some code to vue.config.js to start the server before the client is being compiled.
Preferably this would all work in a hot-reload way.
So far I tried a shell script as Alex78191 suggested:
#!/usr/bin/env bash
node server/server.js &
yarn dev --open
This works, but when I try to stop the servers using ctrl-C, only the yarn-process stops, but the node server keeps on running.
Is there a way in bash to stop all started processes (background and foreground) with the ctrl-C command?
I was able to get this working with the following bash script:
#!/usr/bin/env bash
node server/server.js &
pid=$!
yarn dev --open
trap "kill ${pid}; exit 1" INT
This script is a little bit more complex than you might expect to make sure that all child processes stop when this script stops (using ctrl-C). For more information on stopping child processes I found some help here: how-can-bash-script-do-the-equivalent-of-ctrl-c-to-a-background-task