Why doesn't gcloud app deploy include my custom made module? - node.js

In my Node application script I require a custom made module which has its own dependencies. In local development this all works fine and everything works as expected. However, when I want to deploy my application as a whole through gcloud app deploy the following error occurs:
Updating service [myapp]...failed.
ERROR: (gcloud.app.deploy) Error Response: [9]
Application startup error:
> myapp#1.0.0 start /app
> node server.js
internal/modules/cjs/loader.js:584
throw err;
^
Error: Cannot find module 'mycustommodule'
Does this have anything to do with that maybe gcloud tries to download all node modules for itself from the NPM server and therefore obviously can't find my local module? I can't figure out how to include my own node modules (that also have their own dependencies).
I thank you for thinking along with me in advance.
Help is much appreciated.

When you run the gcloud app deploy command, the SDK automatically creates a .gcloudignore file that pretty much works like .gitignore and filters out some files or directories that won't be deployed.
.gcloudignore by defaults include the node_modules/ directory so your installed dependencies aren't uploaded alongside your code. You can remove this entry from the .gcloudignore and try to deploy again.

Related

Vite manifest not found laravel hostinger

we uploaded our working laravel code on hostinger (shared servers).
Once uploaded we are having this error : Vite manifest not found at: /home/.../blog/public/build/manifest.json
Missing Vite Manifest File
We deleted the line #vite(['resources/css/app.css', 'resources/js/app.js']) from the code.
the application works this time but css and js of login doesn't work.
Do you have any idea of the issue please ?
Best regards,
Hello There hope it's not late.
In order to use vite in your Laravel project for the installed UI files in the Authentication Module, you have to migrate to your project and run the following commands.
npm install
npm run dev
But as long as you are in production run the below command.
npm run build
Then you'll be good to go.
shared hosting is sucks because we don't have ssh access and have very limited choice to do. But it is really cheap. so here is what I do to upload laravel 9 with vue.js on board with vite at hostinger shared hosting.
run npm run build on local
upload all files outside public_html
copy all the data at public directory to public_html. (copy not move)
that should resolve Vite manifest not found error

Deploying next app to Azure fails because node_modules need to be re-installed

I'm creating a build in Azure pipelines and copying node_modules as well as 'out' folder, package.json, package-lock.json, next.config.js and .next folder. I copy all of these into an artifact directory.
I then zip this as an artifact and then do a zip deploy to Azure App Service Linux Web app.
However running npm start (which just points to next start in the package.json) doesn't work as it complains about next not being found in node_modules (even though its there)
What do I need to do to get it work?
If I download the zip file and unzip it locally, it doesn't work either even though all the node_modules are there. I need to run npm ci to be able to get next start to work. How come?
Aren't I meant to just be able to copy node_modules across and everything should just work?
Also bonus points - do I need to force next to start on port 8080 on azure? The default port 3000 doesn't seem to work?
And Azure docs say that npm install is run when package.json is detected. However that's clearly not happening either.
Any help and insights would be most appreciated!
If anyone is trying to deploy Next.js SSR apps to Azure Web apps, the issue is the copying of the node_modules and the config of next.config.js
I was using the File Copy task in my yml file. This isn't good enough.
You have to use cp -paR node_modules to your artifact folder.
We don't have a server.js file but you can't use serverless unless you create a server.js file :) So I changed the next.config.js to server and then it all works without a server.js file.

Serverless deployment to AWS Lambda missing modules?

First time dealing with serverless here. Have successfully deployed using serverless deploy after following the guide to migrating an existing express app over to serverless. But aws lambda keeps throwing an error:
“errorType”: “Runtime.ImportModuleError”,
“errorMessage”: “Error: Cannot find module ‘serverless-http’\nRequire stack:\n- /var/task/app.js\n- /var/runtime/UserFunction.js\n- /var/runtime/index.js”,
So I’m confused. What am I doing wrong? The guide to converting an existing express app didn’t say we’d need to create an AWS Lambda Layer, but since it seems like Lambda can’t find the serverless-http module, does it mean that creating a layer is the fix?
Edit: my .zip file seems to only be an express.js file. I'm not sure if that's unusual but reading online reveals that most people seem to have a node_modules folder zipped up as well? I presume the lack of a node_module folder in the .zip file is causing this runtime.ImportModuleError fail? How do I get serverless to add a node_modules folder if that's the case?
node_modules folder is generally packaged with your code -- provided it exists in your directory (does it?).
If node_modules isn't installed on your local machine, then you can create it by using the npm install command. This command will install all the dependencies listed in the package-lock.json file (or package.json) -- sorry I'm not a node guy :(.
But it definitely sounds like you're not uploading your node_modules folder because it's not on your local machine. You have to initialize the directory first.

Vue.js Heroku deploy not working

I'm trying to deploy a Vue.js application I made to Heroku, but I keep getting Cannot find module '/app/index.js'.
I feel like I'm just missing something small. Here is the git repo if you are wanting to look through the code. https://github.com/Relofr/calculator
You need app.js (as an example) file in your main directory with basic server configuration. You also have to run npm run build before deploying your app.
Follow this tutorial:
https://medium.com/netscape/deploying-a-vue-js-2-x-app-to-heroku-in-5-steps-tutorial-a69845ace489
You don´t have any file with the name index.js try to rename ./src/main.js to ./src/index.js

deploy to google cloud platform flex env does not include directories?

AFAIK when using the google cloud sdk shell to deploy to the google cloud platform flex environment the deploy does not include the directories. For example, I'm following this nodejs express tutorial - https://cloud.google.com/nodejs/resources/frameworks/express. I can run the app locally. I deploy using gcloud app deploy running it in the same directory as app.yaml. However, after the deployment I get an application startup error:
node ./bin/www:
module.js:471`
throw err;
Error: Cannot find module '/app/bin/www'
I am able to deploy and run the hello world nodejs tutorial app, but that app has no sub-directories. However, if I modify that app to use EJS and put .ejs files in a 'views' folder and then deploy, the deploy works but the views folder is missing! I've verified that it is missing by using 'fs' in app.js to print out the files and directories of the current folder and guess what - NO directories except the node_modules folder which gets created during the deployment.
I've also tried deploying a python flask app that seems to have the same error (basically it cannot find a template because the templates folder does not exist...).
Has anyone else experienced this? Do I need to do something special in the deploy? I'm very surprised that not even Google's own sample tutorial app does not deploy.
Thanks!
I spent my whole day on the same issue. It looks like it was a problem with the new gcloud sdk shell. You can downgrade your version by 'gcloud components update --version=137.0.1'
It workes for me

Resources