Zeit builds failing - Error: No output directory named "build" found - node.js

As of 1/5/20 all of my builds are failing that are deployed on Now. I was getting the warning that node 8.x was no longer supported so I specified an engine version of 12.x in my package.json, this successfully stopped the warning from popping during deployment but I'm still receiving the following error
Error: No output directory named "build" found.
I thought maybe a recent change I pushed was causing this but going back and redeploying old deployments that built successfully now received this error. I'm wondering if something on the Now platform changed that I wasn't aware of because it does not seem that code I've pushed recently was the catalyst for this error.
It's also very odd since right before this error the deployment log shows the following
Creating an optimized production build...
Compiled successfully.
File sizes after gzip:
207.04 KB build/static/js/2.7d84160a.chunk.js
11.64 KB build/static/js/main.65999b58.chunk.js
1.24 KB build/static/css/main.cacda93c.chunk.css
762 B build/static/js/runtime~main.a8a9905a.js
The project was built assuming it is hosted at the server root.
You can control this with the homepage field in your package.json.
For example, add this to build it for GitHub Pages:
"homepage" : "http://myname.github.io/myapp",
The build folder is ready to be deployed.
So it looks like the build folder is created but now for some reason now can't find it.
My now.json looks like this
{
"version": 2,
"name": "appname",
"public": false,
"builds": [
{ "src": "package.json", "use": "#now/static-build" },
{ "src": "index.js", "use": "#now/node-server" }
]
}
Any idea why my deployments would suddenly start failing in the last day?

Classic case of finding the solution as soon as I post on stackoverflow...
Not sure which tutorial I followed when first spinning this up but in my package.json I had my now-build script set to
react-scripts build && mv build dist
I removed the last bit of that so now my now-build script is simply
react-scripts build
and all is well again.
I couldn't really tell you why I set this, I just blindly followed the tutorial. For the past 4 months, this has worked, not sure why yesterday it started throwing errors, oh well.

Related

Node.js live debugging in VSCode doesn't work

I have a small project (but issue also appears on the one created by npx create-react-app my-app). I use VsCode and developing inside container (https://code.visualstudio.com/docs/remote/containers) . Dockerfile is very minimal:
ARG VARIANT="16-bullseye"
FROM mcr.microsoft.com/vscode/devcontainers/javascript-node:0-${VARIANT}
devcontainer.json has, almost, just defaults:
{
"name": "Node.js",
"build": {
"dockerfile": "Dockerfile",
"args": { "VARIANT": "16-bullseye" }
},
"settings": {},
"extensions": [
"dbaeumer.vscode-eslint"
],
"remoteUser": "node"
}
To debug, I run npm start , then I (for the 1st time) i click on Debug URl.
On macOS everything works, including file monitoring, so when I change js file, npm is recompiling instantly.
On Windows 11 however, the last part doesn't work - I need to stop and start npm manually, to have changes implement.
I've even tried to remove .vscode directory from my profile - no change here...
Any idea what is going on? Why it does work on macOS and doesn't work on Windows ?
I have the same extensions on both systems...I just can't find what is going on with Windows machine...
EDIT: the issue seems to be related to "Remote Development" extension for vscode . Issue is present only when using this extension on Windows. So I've opened a bug there: https://github.com/microsoft/vscode-remote-release/issues/6633

pm2+ not showing versioning when using ecosystem file

I'm using PM2+ to manage my NodeJS deployments.
Usually, when I deploy an application with pm2 start src/app.js, I get details about versioning like in the screenshot below. However, when I deploy using an ecosystem file I only get N/A:
PM2 normally extracts this information directly using vizion.
But since it didn't work with the ecosystem file, I specified the GitHub repository directly just like the documentation stated.
This is my current pm2-services.json ecosystem-file:
{
"apps": [
{
"name": "my-node-app",
"cwd": "./my-node-app-repo-folder",
"script": "src/app.js",
"env": {
"NODE_ENV": "production"
},
"repo": "https://github.com/MyUserName/MyNodeAppRepo.git",
"ref": "origin/master"
}
]
}
For the ref field, I also tried putting refs/remotes/origin/master, remotes/origin/master and master.
Sadly none of them worked (I made sure they are correct using git show-ref).
Additional info:
NodeJS Version: v15.11.0
NPM Version: 7.6.3
PM2 Version: 4.5.6 (latest, by the time of writing this)
So, how do I get the Versioning field to display correctly?
Note: This isn't really an issue but rather a minor inconvenience. I just want to know what I'm doing wrong.

Yoga server deployment to the now.sh shows directory listing instedad the application

I can run the app locally without any issue by yarn start command. here I have provided photographs which represent my problem. I googled and noticed several people faces the same problem. but their context is different.
By default, Now publishes your files as a static directory. You can add a builder to your now.json file to tell Now how to build and deploy your site.
In a case where app.js contains a web server application, your now.json might look like this:
{
"version": 2,
"name": "my-project",
"builds": [
{"src": "app.js", "use": "#now/node"}
]
}
This tells Now to use the #now/node builder to generate a lambda that runs app.js to respond to requests.
If your app is purely js+html to be run on the client machine, you wouldn't need the lambda, but you can still build the source before deploying it as static files with #now/static-build.
Check out the Now docs for more info: https://zeit.co/docs/v2/deployments/basics/#introducing-a-build-step

project deployment to zeit reads "warning project is missing a now.json file with version ###"

when deploying my project up to my zeit clipboard, after the success deployment a warning sign appears stating "your project is missing a now.json file with version ###". then i went to the zeit website to get the new version for now but it doesnt work. byt the way It's a node project. any help is appreciated
Updating to the latest version won't resolve this warning. Having the now.json files allows you to specify options. Zeit added support for additional options, these can be specified in the now.json file. It looks something like this
{
"version": 2.2,
"builds": [
{ "src": "*.js", "use": "#now/node" }
]
}
Note: You can still deploy to Zeit without a now.json file. However, if your project has no now.json file, or has one but no builds property defined, the projects source* files will be deployed directly as the output.
Learn more about now.json and what available options exist here
Learn more about sources and outputs here
*Sources are files that already exist in your project before deploying and can be used to define the output

Bluemix error: Module version mismatch

I am trying to run a node.js application that uses PouchDB (a local CouchDB implementation). I can run this successfully locally and even upload it and build it on my Bluemix instance. However, whenever I send a request to my app, I do not get a response and I see the following error in my Bluemix console:
[Error: Module version mismatch. Expected 46, got 14. This generally implies that leveldown was built with a different version of node than that which is running now. You may try fully removing and reinstalling PouchDB or leveldown to resolve.]
I have tried to add npm rebuild into my build pipeline above the npm install, which I can see does indeed do a rebuild. However, I still get the previous error.
A bit about my app: It is a bot for the Slack platform. A user sends a command and my Bluemix app then responds. My Bluemix app has multiple documents that PouchDB stores. As I say, all this runs and responds correctly on my development machine.
Here is my package.js for reference:
{
"name": "XXXXXXXXXXX",
"version": "0.x.0",
"description": "XXXXXXXXXXXX",
"main": "app.js",
"scripts": {
"start": "node app.js"
},
"repository": {
"type": "git",
"url": "XXXXXXXXXXX"
},
"keywords": [
"slack",
"bot",
"nodejs"
],
"author": "xxxxxxxxx",
"license": "MIT",
"dependencies": {
"bluebird": "^3.1.1",
"body-parser": "^1.14.2",
"cfenv": "^1.0.3",
"cheerio": "^0.19.0",
"express": "^4.13.3",
"pouchdb": "^5.1.0",
"request-promise": "^1.0.2"
},
"engines": {
"node": "^4.2.x",
"npm": "^2.14.x"
}
}
Also some additional history: I ran a prior version of my app on Bluemix when I was using MongoDB instead of PouchDB. My node version at the time was the default that Bluemix gave me when I started, which was version 0.12.x. However, this version didn't support arrow functions, which I make heavy use of now. Hence, the bump to node 4.2.x.
Thanks!
Edit: After some digging I found out that 'leveldown' (a dependency of PouchDB) makes use of npm prebuilds where available. What this means is that if a prebuild is available on their GitHub it will be downloaded instead of the source, as a convenience. Looking through the logs I notice that version 1.4.2 is being downloaded as the prebuild version through Bluemix. However, there is a version 1.4.3 available that looks like it solves my 'Expected 46, got 14` issue. So the new question is why is Bluemix doing this and how can I rectify it?
I tried to push on Bluemix the same version that you are using ("^5.1.0") in your package.json and it is working fine, even using node engine "4.0.x".
Moreover according to CF infrastructure, the runtime is build during application staging step, so the pouchdb module should be built with the right dependencies and references.
Have you tried to push your application again in order to force a full application restage?
If yes, the first step to understand what is going on is to get the application logs during the staging process and also as soon as this error message is returned.
So, on your terminal, run the following commands:
1 - cd into your source directory
2 - connect to Bluemix API
cf api https://api.[REGION].bluemix.net

where [REGION] is one of
eu-gb for United Kingdom
ng for US South
au-syd for Sydney
3 - Login to Bluemix and choose the right ORG and SPACE
cf login -u [BLUEMIX USERNAME]
cf target -o [BLUEMIX ORG] -s [BLUEMIX SPACE]
4 - push your application and, as soon as it has been staged, run
cf logs [app-name] --recent > staging_output.txt
5 - tail the application logs, running
cf logs [app-name]
and without closing it make the request that is generating the error message
6 - check the output generated at step #5 for details on where in the code your application is failing and on the failing module
After a lot of debugging the answer, as ever, was to delete my Bluemix application first and then push a new version via the build system. The leveldown prebuilt npm package that was causing the error was cached somewhere. I could only get rid of this by deleting my app. Nothing special there.

Resources