I'm trying to Host my bot "chompbot" in Heroku.
But when i change Procfile from web to worker, does not change anything.
I've tried
Here is my package.json
"name": "chompbot",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"start": "node index.js"
},
"author": "",
"license": "ISC",
"dependencies": {
"discord.js": "^11.5.1",
"mysql": "^2.17.1"
}
}
And here is my Procfile
worker: index.js
When i commit and push, anything happens on "Web", and do not appears "Worker" option
( Ps.: The MySql database is fully working on cloud, so, can't be the dependencies )
Can someone help me to change from Web to Worker?
http://prntscr.com/pb21qs
Your worker should be the script that starts you server, index.js is only the file name. What you want to do is to use your npm start script instead of index.js
Related
I have the following configuration in a root workspace. The strange thing is that for backend it works, but for frontend - doesn't, no matter how I rename this
{
"private": true,
"name": "root",
"workspaces": [
"packages/frontend",
"packages/backend"
],
"scripts": {
"client": "yarn workspace frontend start",
"client-test": "yarn workspace frontend test",
"server": "yarn workspace backend start",
"start": "conc --kill-others-on-fail \"yarn client\" \"yarn server\""
},
"devDependencies": {
"concurrently": "^7.6.0"
}
}
And it always says: $ yarn workspace frontend test
error Unknown workspace "frontend".
info Visit https://yarnpkg.com/en/docs/cli/workspace for documentation about this command.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
I tried to start from all directories, nothing works
The thing is that it does not matter how folders are called inside of "packages", the important thing is that package.json of each workspace should be called correspondingly:
{
"name": "frontend",
"version": "1.0.0",
"private": true,
...
}
So I am trying to make my procfile for Heroku CLI but I don't think Heroku is recognizing it because when I do $ git push heroku main the Procfile doesn't work rather it does npm start rather than what's written in the Procfile but it works when I run it locally like heroku local --procfile=procfile. And I'm pretty sure that the P of my profile is correct so that's not the issue
When I do $ git push heroku main ( Updated ): https://i.stack.imgur.com/gGcSZ.png
When I do $ heroku local --procfile=procfile
https://i.stack.imgur.com/BErzz.png
Folder Pic:
https://i.stack.imgur.com/blHei.png
Procfile : worker: node index.js
Full git view + commiting :-
https://i.stack.imgur.com/KYOHw.png
package.json :
"name": "ban-counter",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"discord.js": "^13.6.0"
}
}
Just had to add "start": "node index.js" to the scripts in the package.json therefore now resulting in:
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
start": "node index.js"
},
I am trying to import components in a shared package in a monorepo, but am unable to do so.
I have the following package.json files under the root of a repo that I want to run as a monorepo. /apps/billing is a create-react-app. /apps/shared is going to contain components for billing and other apps.
/package.json
{
"name": "root",
"version": "1.0.0",
"private": true,
"description": "",
"main": "index.js",
"workspaces": [
"apps/*"
],
"scripts": {
"billing": "cd apps/billing; yarn start"
},
"author": "",
"license": "ISC",
"dependencies": {}
}
/apps/billing/package.json
{
"name": "#root/billing",
"version": "0.1.0",
"private": true,
"dependencies": {
<snip>
},
}
/apps/billing/shared.json
{
"name": "#root/shared",
"version": "1.0.0",
"main": "index.js",
"license": "MIT"
}
In the /apps/billing directory I tried to run yarn add #root/shared and get the following output:
error An unexpected error occurred: "https://registry.yarnpkg.com/#root%2fshared: Not found".
In billing, when I try to import a component from shared
import Button from '#root/shared/components/Button';
I get
Module not found: Can't resolve '#root/shared/components/Button'
Are there additional steps to setup a yarn monorepo?
It's wrong structure for monorepo.
Also you've wrongly named /apps/billing/shared.json it should be package.json instead of shared.json
At first your package.json in the root folder should be named eg. #name-of-your-app/monorepo
then packages under your root.
fe. in apps/billing
{
"name": "#name-of-your-app/billing-app",
"version": "0.1.0",
"private": true,
"dependencies": {
// any dependencies
},
then your shared components:
each should be in its own directory
each should have its own package.json
Let's say that you have shared/Button
then Button should be in its own directory and contain package.json
eg. of shared/Button/package.json/
{
"name": "#name-of-your-app/button",
"version": "0.1.0",
"private": true,
"dependencies": {
// any dependencies
},
and if you want to use this button in your billing-app
then you should at first add this as dependency IMPORTANT watchout for version of your button in package.json, the same should be installed as dependency in your app, otherwise it will finish up with bunch of errors.
-Then when you want to import this button in any component under your billing-app then import should look like this:
import Button from '#name-of-your-app/button'
You can read more about workspaces here:
yarn workspaces
Also I recommend to read more about monorepo structure fe. here
Hello this is my json file format and this works well on my local machine when I run node index.js.
{
"name": "a-simple-nodejs-website",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "node index.js"
},
"author": "Theodore Kelechukwu Onyejiaku",
"license": "ISC"
}
But Heroku tells me:
Application error
An error occurred in the application and your page could not be served...
You need to mention engine in package.json as below
{
"name": "a-simple-nodejs-website",
"version": "1.0.0",
"description": "",
"main": "index.js",
"engines": {
"node": "10.x"
},
"scripts": {
"test": "node index.js"
},
"author": "Theodore Kelechukwu Onyejiaku",
"license": "ISC"
}
Check your Application Port in index.js. if you set to static port change as below:
const PORT = process.env.PORT || 5000
pass this port in your server listen method.
There was no start script in the json file so add => "start": "node index.js".
Fool code sample is below
{
"name": "a-simple-nodejs-website",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "node index.js",
"start": "node index.js"
},
"author": "Theodore Kelechukwu Onyejiaku",
"license": "ISC"
}
with a simple package like
{
"name": "test",
"version": "0.1.0",
"description": "test",
"main": "hello-world-server.njs",
"scripts": {
"start": "node hello-world-server.js"
},
"repository": "",
"keywords": [
"node.js",
"eclipse",
"nodeclipse"
],
"author": "",
"license": "MIT",
"readmeFilename": "README.md"
}
i can run (from command line) :
npm start
and all is fine. but from eclipse (nodeclipse), with npm ... , from the run configurations, all I get is:
> test#0.1.0 start /Users/chrismarx/Documents/workspaces/yardmap-3.5.0/test
> node ./hello-world-server.js
execvp(): No such file or directory
anybody know how to fix this? i just installed nodeclipse into a fresh install, i believe i've got the latest version 0.15.1.201404300203
Usually in GUI select .js file, right-click Run As -> Node App.
Later can select from Run drop down menu
While npm start would be from command line.
In your case, you can right click on /bin/www -> Run As -> Node App.