Vercel build complaining about .env.local? - deployment

My NextJS app build is compiling successfully but then suddenly errors because of something in .env.local — I was under the impression that this file was ignored, and besides, nothing has changed in this file. Any idea why this happens?
The last few lines in the log before the error:
16:55:48.579 info - Compiled successfully
16:55:48.579 info - Collecting page data...
16:55:49.442 Error: Please define the MONGODB_URI environment variable inside .env.local

Your application is searching for the MONGODB_URI environment variable, please find where you use that variable. If you need that then create an env file as .env.local and put your MONGODB_URI code into it.
MONGODB_URI=YOUR_VALUE

Related

sam build when deployed in github now fails

Last week I managed to successfully deploy an AWS Lambda function (verified in the AWS console). This morning, I can no longer update the Lambda function. After deleting the Lambda function and pushing changes again, the Lambda was still not able to be created. Instead I get the following traceback:
Build Failed
Error: PythonPipBuilder:ResolveDependencies - The directory '/github/home/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/github/home/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Invalid requirement: 'Warning: The lock flag'
In the workflow deploy file:
- name: Build Lambda image
run: sam build
I don't know exactly what has changed to now cause this error. I tried the flag --use-container which successfully moves on the next step of deploying the Lambda image, however there I now encounter further error messages. I'd like to understand why before adding the --user-container flag, I didn't encounter this error. Is this --use-container flag necessary when not using the sam cli?
Further info
Building via the sam cli tool works, not when pushed via the Github actions workflow.

prisma - getting environment variable not found error message when running graphql query

I am getting this error message from prisma when I am running the GraphQL query.
Environment variable not found: DATABASE_URL.\n --> schema.prisma:6\n | \n 5 | provider = \"postgresql\"\n 6 | url = env(\"DATABASE_URL\")\n | \n\nValidation Error Count: 1",
At first, I didn't have the .env file in any of my project folders, then I added it with the link to the database url, still not working.
Here is the folder structure:
This is what I have inside my .env file looks like -
DATABASE_URL="postgres://postgres:mypassword#db.pqtgawtgpfhpqxpgidrn.supabase.co:5432/postgres"
If anybody running into this issue, just run npx prisma generate. This will re-establish the link between schema.prisma and .env file.
In my case I wanted to run Prisma Studio with NextJS that stores all environment variables in .env.local, so I need to load the file first.
npm install -g dotenv-cli
dotenv -e .env.local -- npx prisma studio
Here is a link to the official Prisma docs on how to load .env files manualy.
I had this issue in my NextJs project. after changing the .env.local file to .env everything worked.
Others like me (new to Prisma, following the Remix.run jokes-app tutorial) might be relieved to learn it's not just you: there was a regression in Prisma 3.9.0, fixed in 3.9.1 in early Feb 2022. https://github.com/prisma/prisma/issues/11570
"prisma db pull doesn't read .env file and errors with Environment variable not found: DATABASE_URL"
If you try with a schema completed and an empty db, you have this error. Try "prisma db push" first and after verify with "prisma studio".
In my case I encountered a weird problem with the .env file itself, I created the file using Powershell's echo. Apparently, manually creating it in Vscode solves the problem.

Unknown property errors trying to do a with Flyway migration with per script config files

My company is evaluating Flyway for database releases. We have an AWS PostgreSQL version 11.2 database and I have installed Flyway Community Edition version 6.1.2.
I have successfully baselined the database and run several basic DDL scripts using Flyway migrate. However now I am testing a more complicated scenario in which I need to run multiple scripts as one migration but each script has to connect as a different PostgreSqL user. I have tried to do this by setting up two sql files each with their own config file as described here: https://flywaydb.org/documentation/scriptconfigfiles
Every time I run the migrate command I get a property error: "ERROR: Unknown script configuration property: flyway.user" or "ERROR: Unknown script configuration property: user", etc, etc.
For debugging purposes I removed one sql and config combo so that I now only have one file each. The files are named V2020.1.14.08.41.00__role_test1.sql and V2020.1.14.08.41.00__role_test1.sql.conf. I did confirm that any changes to that config file are being picked up by the migrate command. My config file contains the following properties (values changes for security reasons):
flyway.url=jdbc:postgresql://...
flyway.user=user1
flyway.password=password
flyway.schemas=test
I have also tried removing the flyway prefix:
url=jdbc:postgresql://...
user=user1
password=password
schemas=test
And removing the url parameter (both flyway.url and url) so the migration reads that value from the default flyway.conf file. Example:
user=user1
password=password
schemas=test
I get the errors every time. Anyone have any ideas? All help is greatly appreciated.
There is a typo in your code:
flyeay.user=user1
It should be:
flyway.user=user1

What causes error "Connection test failed: spawn npm; ENOENT" when creating new Strapi project with MongoDB?

I am trying to create a new Strapi app on Ubuntu 16.4 using MongoDB. After stepping through the tutorial, here: https://strapi.io/documentation/3.0.0-beta.x/guides/databases.html#mongodb-installation, I get the following error: Connection test failed: spawn npm; ENOENT
The error seems obvious, but I'm having issues getting to the cause of it. I've installed latest version of MongoDB and have ensured it is running using service mongod status. I can also connect directly using nc, like below.
$ nc -zvv localhost 27017
Connection to localhost 27017 port [tcp/*] succeeded!
Here is an image of the terminal output:
Any help troubleshooting this would be appreciated! Does Strapi perhaps log setup errors somewhere, or is there a way to get verbose logging? Is it possible the connection error would be logged by MongoDB somewhere?
I was able to find the answer. The problem was with using npx instead of Yarn. Strapi documentation states that either should work, however, it is clear from my experience that there is a bug when using npx.
I switched to Yarn and the process proceeded as expected without error. Steps were otherwise exactly the same.
Update: There is also a typo in Strapi documentation for yarn. They include the word "new" before the project name, which will create a project called new and ignore the project name.
Strapi docs (incorrect):
yarn create strapi-app new my-project
Correct usage, based on my experience:
yarn create strapi-app my-project
The ENOENT error is "an abbreviation of Error NO ENTry (or Error NO ENTity), and can actually be used for more than files/directories."
Why does ENOENT mean "No such file or directory"?
Everything I've read on this points toward issues with environment variables and the process.env.PATH.
"NOTE: This error is almost always caused because the command does not exist, because the working directory does not exist, or from a windows-only bug."
How do I debug "Error: spawn ENOENT" on node.js?
If you take the function that Jiaji Zhou provides in the link above and paste it into the top of your config/functions/bootstrap.js file (above module.exports), it might give you a better idea of where the error is occurring, specifically it should tell you the command it ran. Then run the command > which nameOfCommand to see what file path it returns.
"miss-installed programs are the most common cause for a not found command. Refer to each command documentation if needed and install it." - laconbass (from the same link, below Jiaji Zhou's answer)
This is how I interpret all of the above and form a solution. Put that function in bootstrap.js, then take the command returned from the function and run > which nameOfCommand. Then in bootstrap.js (you can comment out the function), put console.log(process.env.PATH) which will return a string of all the directories your current environment is checking for executables. If the path returned from your which command isn't in your process.env.PATH, you can move the command into a path, or try re-installing.

Resetting json-server to the contents of db.json

NOTHING I do will get json-server to acknowledge changes to the db.json file. After reading https://github.com/typicode/json-server/issues/177. I have tried clearing the cache and closed all browser connections etc. (which is a pain enough in a workflow...) but still the data and schema persists in its last used state.
REST calls change the data, and the changes can be seen, that is working fine. But I need to change the schema...
How do I get json-server to restart using what is in the db.json file??
In case it helps anyone else. I started json-server from the wrong folder, so it created and loaded a default db.json. I did not catch the warning
Oops, db.json doesn't seem to exist
Creating db.json with some default data
on the very first startup. So I was altering the "wrong" file!!! Just a note in case anyone else gets caught out.
Steps:
Navigate to the path where json server is installed (json-server-master folder).
Rename the db.json as db.json_bkp
Restart the json server from command prompt
json-server --watch db.json
The db will be reset to the default values.
I've faced the similar issue.
Please check the db.json file that json-server is accessing and change it accordingly.
In my case, I was changing a different file than the correct one.
Please check for db.json file in the directory where you first installed/run the json-server. Change it according to your requirement.
Restart json-server so that changes will effect.
Go to the folder where your db.json file resides. then run the command json-server --watch db.json
I went through the same issue. I visited the the db directory (where the db.json file is situated).
Run json-server --watch db.json at the command prompt, while you are at the db directory.