Trying to deploy Node server to Vercel but getting the following error:
The structure:
Besides the versel.json file is present:
{
"version": 2,
"builds": [
{
"src": "./server.js",
"use": "#vercel/node"
}
],
"routes": [
{
"src": "/(.*)",
"dest": "/"
}
]
}
So what could be the reason for the error?
Related
I'm trying to redirect a URL using the Chrome declarativeWebRequest API but it does not work.
The match pattern in the "permissions" key worked with Manifest V2 but it's now throwing a Permission '*://www.youtube.com/*' is unknown or URL pattern is malformed error in V3.
manifest.json:
{
"manifest_version": 3,
"name": "Redirect Test",
"version": "0.0.1",
"permissions": [
"declarativeNetRequest",
"*://www.youtube.com/*"
],
"host_permissions": [
"*://www.youtube.com/*"
],
"declarative_net_request": {
"rule_resources": [
{
"id": "1",
"enabled": true,
"path": "rules.json"
}
]
}
}
rules.json:
[
{
"id": 1,
"priority": 1,
"action": {
"type": "redirect",
"redirect": {"url": "https://www.google.com"}
},
"condition": {
"urlFilter": "*://www.youtube.com/*",
"resourceTypes": [
"main_frame"
]
}
}
]
I'm using Chrome 88.0.4324.104
The manifest documentation for declarative net requests at the time of posting isn't exactly accurate.
This is the
Permissions key in manifest.json from the documentation:
"permissions": [
"declarativeNetRequest",
"declarativeNetRequestFeedback",
"*://example.com/*"
],
However, the site should be specified in just host_permissions instead:
"host_permissions": [
"*://example.com/*"
],
It should be noted that this explicit declaration is only necessary if action.redirect is specified like in this example:
{
"id": 1,
"priority": 3,
"action": {
"type": "redirect",
"redirect": {
"regexSubstitution": "www.youtube.com/embed/"
}
},
"condition": {
"regexFilter": "(www\\.youtube\\.com\/watch\\?v=)",
"resourceTypes": [
"main_frame"
]
}
}
I am running a simple nodejs form processing app on zeit now server and deploying using now CLI scripts.
This Node app although working well on the localhost within the said port number (like this: http://localhost:8081/myaction), however the same function is not workinig for me on the zeit server wherein I replace the localhost with the server URL given by NOW build script.
Here is my now.json and I am also providing access to the git repository which has the node server app thaat processes the form, sends an E-mail and serves a Thank You page in the last step.
Node Server App repo: https://github.com/jnsrikanth/node-form-server2
now.json file contents:
{
"version": 2,
"builds": [{ "src": "index.js", "use": "#now/node-server" }],
"routes": [
{
"src": "/public/thank-you/dist/",
"dest": "/index.html",
"methods": ["GET"]
},
{
"src": "/",
"dest": "/index.js",
"methods": ["POST"]
}
]
}
The package.json and the remaining code can be found in the repository. It would be great if I can find some pointers here.
Also please note that in my form I am calling action="https://zeit-url:8081/myaction" method="POST" where 8081 is the port on which the express app is listening for processing the POST method with form data.
In your now.json replace / with /myaction
...
{
"src": "/myaction",
"dest": "/index.js",
"methods": ["POST"]
}
...
And just call https://zeit-url/myaction (without port number)
I hope it will help you
I would suggest you to convert that now.json into a vercel.json and, based on the github repo you provided, update it so looks like:
"version": 2,
"builds": [
{
"src": "index.js",
"use": "#vercel/node"
}
],
"routes": [
{
"src": "/public/thank-you/dist/",
"dest": "/public/index.html",
"methods": ["GET"]
},
{
"src": "/",
"dest": "/index.js",
"methods": ["POST"]
}
]
You need to verify this server runs without problems on local machine.
Since you are using the builds vercel.json option, you need to ensure all the dependencies, as node_modules etc are uploaded to vercel, either by deploying file from the vercel-cli, or using some pipeline or CI action.
I'm trying to deploy a node / express API that has several endpoints for use at now.sh.
My question is how to correctly configure the file now.json.
leave the image where you can see the complete structure of the project, the main path would be the ./src/ where are all the folders and files.
The main entrypoint is http://localhost:3000/api/v1/ for localhost
I delete the file now.json and from the terminal I paste the now command, and then I generated the deployment in the following path
https://ryuanime.chrismichael.now.sh
But when I try to go to https://ryuanime.chrismichael.now.sh/api/v1 it shows me 404: NOT_FOUND
Image
source code
now.json
{
"version": 2,
"name": "ryuanime",
"builds": [
{
"src": "src/index.ts",
"use": "#now/node-server"
}
],
"routes": [{"src": "/(.*)", "dest": "/src/index.ts"}]
}
For some reason it worked by referring to
"src": "./src/index.ts"
and not
"src": "src / index.ts",
{
"name": "ryuanime-api",
"version": 2,
"builds": [
{
"src": "./src/index.ts",
"use": "#now/node-server"
}
],
"routes": [
{ "src": "/(.*)", "dest": "/src/index.ts" }
]
}
I have an electron app and I got this error when run electron-builder build.
Error: Application entry file "main.js" in the "/project/dist/release/mac/demo.app/Contents/Resources/app.asar" does not exist. Seems like a wrong configuration.
This is package.json. I have set the main to dist/electron.js but I don't understand why it keep saying main.js doesn't exist.
...
"main": "dist/electron.js",
"build": {
"productName": "demo",
"appId": "com.auspost.pos",
"files": [
"dist/",
"node_modules/**/*",
"package.json",
"dist/electron.js"
],
"directories": {
"output": "dist/release"
},
"dmg": {
"contents": [
{
"x": 130,
"y": 220
},
{
"x": 410,
"y": 220,
"type": "link",
"path": "/Applications"
}
]
},
"win": {
"target": [
"nsis",
"msi"
],
"icon": "./electron/assets/icons/win/app.ico"
},
"publish": {
"provider": "github"
}
},
...
"devDepencencies": {
"electron": "^5.0.2",
"electron-builder": "^20.41.0",
"electron-webpack": "^2.6.2",
}
Finally figure out that because the project has electron-webpack dependency which works as a base template for electron build configuration. There are some fields are defined there which get extended.
The fix for that is either remove electron-webpack from your project dependencies or use electron-webpack convention to manage your project.
I had a similar issue:
Application entry file "index.js" in the ".....\dist\win-unpacked\resources\app.asar" does not exist.
The fix for me was to add
main: "main.js"
in the package.json of the generated app, so .\app\package.json.
Seems like without this electron-builder 21 (electron 6) is looking for a "index.js" file.
I encountered the error when selecting the production version of my entry file which was in a different folder than the source production file.
Here is the relevant config section that got my app to build:
"build": {
"files": [
"electron-settings.json",
"package.json"
],
"extraResources": [
{
"from": "../build/backend/min",
"to": "app",
"filter": [
"**/*"
]
},
{
"from": "desktop/node_modules",
"to": "node_modules"
}
],
"mac": {
"extraResources": [
{
"from": "build/osx",
"to": "app/build/osx"
}
]
}
}
I am trying to deply my node.js app to NOW,
But when i deploy all i see is the root folder with all the files...
I am supposed to have an index.html file, but i dont know where this happens or where i should set this up?
In webpack? in start.js?
Any ideas?
In my project, i have start.js and app.js
So I guess, I should use start.js on the now.json config file
{
"version": 2,
"builds": [
{ "src": "start.js", "use": "#now/node" },
{ "src": "index.html", "use": "#now/static" }
]
}
But I get an error and logs like:
'The lambda function size (8.98mb) exceeds the configured limit (5mb). You may increase this by supplying maxLambdaSize to the build config'`
As stated in the error, You have to add maxLambdaSize to your build config.
{
"name": "Your Project Name",
"alias": ["yourAliasGoesHere"],
"version": 2,
"builds": [
{
"src": "index.js", //put your own stuff here
"use": "#now/node-server",
"config": { "maxLambdaSize": "10mb" } //right here
}
]
}
Increase or decrease the maxLambdaSize as needed.