I've been working on a Firebase functions project, running the service locally for testing.
It was all working fine, but then I moved the source folder to a new location (into source control), and now it won't run, because something, somewhere remembers the old location of the project.
So where the heck is Firebase 'remembering' the original location of the project/source?
And how do I fix it?
More info:
Platform: Windows 7
Node: v6.11.1 (as advised by: https://cloud.google.com/functions/docs/writing)
Below is what the output looks like when I run 'firebase serve --only functions' and hit the service URL.
Ignore the lines with "Failed to emulate..." and "No HTTPS..." - That is normal.
The next "error:" line, and the rest is emitted when the URL is hit.
The important points are:
a) The folder my project is in is shown on the first line (In standard Windows CMD prompt fashion)
b) The "Cannot find module" error is looking in A COMPLETELY DIFFERENT
FOLDER. In fact, it is looking where the project USED to be.
D:\_DEV\svn\FredSays\onGoogleAssistant\functions>firebase serve --only functions
=== Serving from 'D:\_DEV\svn\FredSays\onGoogleAssistant'...
i functions: Preparing to emulate HTTPS functions. Support for other event types coming soon.
! functions: Failed to emulate FredSays
i functions: No HTTPS functions emulated. Support for other function types are coming soon.
error: module.js:471
throw err;
^
Error: Cannot find module 'D:\_DEV\FredSays\actionssdk-say-number-nodejs-master\functions'
at Function.Module._resolveFilename (module.js:469:15)
at Function.Module._load (module.js:417:25)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at process.on.e (D:\_TOOLS\nvm\v6.11.1\node_modules\firebase-tools\node_modules\#google-cloud\functions-emulator\src\supervisor\worker.js:64:28)
at emitTwo (events.js:106:13)
at process.emit (events.js:191:7)
at process.nextTick (internal/child_process.js:758:12)
at _combinedTickCallback (internal/process/next_tick.js:73:7)
at process._tickCallback (internal/process/next_tick.js:104:9)
error: Function worker crashed with exit code: 1
I can't find anything in the project tree listing the old location.
I've tried all of the following:
npm cache clean
firebase init functions
firebase logout & firebase login
DEL /S /Q node_modules & npm install
npm uninstall -g firebase-tools & npm install -g firebase-tools
All of the above are no help.
Please help. My project is dead in the water right now.
I came across your post whilst researching the same problem on my Ubuntu dev environment. I copied some code from an NFS share to my home directory and can't for the life of me get it to run in the functions emulator - one of the issues was that the code was still being run on the NFS mounted path and not the local path where I was running VS Code.
The command you need to re-home the code after you move it is
$firebase use
Active Project: fbgo-9f73a
Project aliases for /home/user/firebase/chappy:
* default (site-ID)
Run firebase use --add to define a new project alias.
then start the emulator
$ firebase serve --only functions,hosting
=== Serving from '/home/user/firebase/chappy'...
i functions: Preparing to emulate functions.
i hosting: Serving hosting files from: public
✔ hosting: Local server: http://localhost:5000
✔ functions: app: http://localhost:5003/site-ID/us-central1/app
Unfortunately I don't have a 'before and after' on this to be 100% sure, please let me know if this fixes it for you.
Related
I have deployed Firebase functions in the past many times. For some reasons, recently (around 2-3 days) I am frequently getting error while deployment. I am using windows to release the code. When I tried with setting up the same project in my Linux system and Mac system the deployment works correctly. What may be the issue for the release from Windows environment.
The following is the issues getting while deployment.
! functions[payment(us-central1)]: Deployment error.
Function failed on loading user code. This is likely due to a bug in the user code. Error message: Error: please examine your function logs to see the error cause: https://cloud.google.com/functions/docs/monitoring/logging#viewing_logs. Additional troubleshooting documentation can be found at https://cloud.google.com/functions/docs/troubleshooting#logging. Please visit https://cloud.google.com/functions/docs/troubleshooting for in-depth troubleshooting documentation.
Functions deploy had errors with the following functions:
admin
cancellation
cost
createStripeCharge
customer
driver
driverLiveTracking
generalSettings
notification
order
payment
To try redeploying those functions, run:
firebase deploy --only "functions:admin,functions:cancellation,functions:cost,functions:createStripeCharge,functions:customer,functions:driver,functions:driverLiveTracking,functions:generalSettings,functions:notification,functions:order,functions:payment"
To continue deploying other features (such as database), run:
firebase deploy --except functions
Error: Functions did not deploy properly.
Following is the deployment command I am using for
"echo Deploying Functions && npm run lint && npm run build && firebase deploy --only functions"
Please share your knowledge over the issue.
Thanks.
I have resolved this issue. On building, I found that the node modules and lib functions are not replacing correctly with the new build. I have done a name changing previously and that are not reflecting in the new build.
Steps followed:
Removed node modules and lib files
Npm install
Npm run serve
And a new build is worked fine as well. I got the same issue using Jenkins build also. I just manually removed the same in server also.
You can find the issue by examining the actual logs. view them using this command
firebase functions:log
The specific issue will be visible there. I sometimes had error as simple as a missing packages in package.json
I have some troubles deploying a Nuxt 2.4 application on Firebase.
I tried these 2 tutorials but they seem outdated:
https://www.youtube.com/watch?v=ZYUWsjUxxUQ
https://github.com/davidroyer/nuxt2-ssr-firebase
With the first tutorial, I could make my app working on local (after few hours and with a lot of modifications for babel integration) but I never could serve or deploy it. I thought the tutorial was old and manipulations can't be exactly done like the guy did.
With the second tutorial, I cloned the repository to try to deploy the example. I had to change 2 things : install Node 8 instead of Node 10 and upgrading firebase-admin to the last version in prod/server dir. Here is what I got:
npm run setup is ok
npm run dev is ok and the project works fine
npm run build is ok
npm run serve fails.
First I got this error :
The Cloud Functions emulator requires the module "firebase-admin" to be version >7.0.0 so your version is too old. You can probably fix this by running "npm install firebase-admin#latest" in your functions directory.
Indeed, the version configured in package.json is the 5.13. I did the update from the prod/server dir, and I get the 8.0.0.
And then I got a different error about gRPC :
Error: Failed to load gRPC binary module because it was not installed for the current system
Expected directory: node-v57-darwin-x64-unknown
Found: [node-v64-darwin-x64-unknown]
This problem can often be fixed by running "npm rebuild" on the current system
I tried npm rebuild as mentionned, without success.
npm run deploy fails.
I get this trace:
i deploying functions, hosting
i functions: ensuring necessary APIs are enabled...
✔ functions: all necessary APIs are enabled
i functions: preparing prod/server directory for uploading...
Error: Error parsing triggers: Cannot find module 'acorn'
Try running "npm install" in your functions directory before deploying.
Of course, I tried the npm install from prod/server dir, but nothing changed.
Is there somewhere i can find a tutorial that can help me deploy my SSR app to firebase ? Thanks in avdance !
EDIT 1 :
After a few modifications on my package.json
upgrading firebase-functions and express to the latest versions
downgrading firebase-admin to the 7.0.0 version
adding acorn
I can serve and deploy but I get a "504 gateway time-out" webpage when I call the URL....
Have you tried to run npm install grpc inside functions folder?
I’m trying to host my web app in Firebase. I runned:
webdev build --output build,
firebase init, and
firebase deploy,
but I received a error message:
Error: There was an issue preparing Hosting files for upload.
So I runned firebase deploy --debug. The error message was:
i hosting: preparing build/web directory for upload...
[2018-08-11T14:30:25.054Z] Error: ELOOP: too many symbolic links encountered, stat 'C:\Users\marco\MyWebApp\WEB\WEBSITE
- Copia\build\web\packages\packages\packages\packages\packages\packages\packages\packages\packages\packages\packages\packages\packages\packages\packages\packages\packages\packages\packages\packages\packages\packages\packages\packages\packages\packages\packages\packages\packages\packages\packages\packages'
Error: There was an issue preparing Hosting files for upload.
How can I resolve this error?
(If I run firebase serve, it works).
Thank you very much!
As mentioned in this answer, ensure that in the firebase.json file you've set the hosting.public field to "build/web":
{
"hosting": { "public": "build/web" }
}
There seems to be an issue with webdev builds at the moment (unless it is a firebase issue). Anyhow, as a workaround, I found that deleting the symlink that causes the loop (build/packages/packages) solved the issue for me.
From the root of your project run this command every time you rerun webdev build -o build:
rm build/packages/packages
After that both firebase serve and firebase deploy worked for me.
Unable to launch firebase serve --only functions,hosting due to following error:
⚠ functions: Failed to load functions source code. Ensure that you have the latest SDK by running npm i --save firebase-functions inside the functions directory.
⚠ functions: Error from emulator. Error: Timeout waiting for emulator start
Already tried running npm i --save firebase-functions as suggested in the functions directory but that doesn't seem to help.
Any help will be much appreciated!
You've probably figured this out by now, but I was able to solve this on OSX by doing two things:
Update your /ect/host file to include the line:
127.0.0.1 localhost
Use sudo to start functions
sudo functions start
I have just deployed my first production Meteor app, but ran into a pretty significant issue. When I tried to run my app, I get the following error:
/home/hiapp/bundle/programs/server/node_modules/fibers/future.js:173
throw(ex);
^
Error: /home/hiapp/bundle/programs/server/npm/npm-bcrypt/node_modules/bcrypt/build/Release/bcrypt_lib.node: invalid ELF header
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at bindings (/home/hiapp/bundle/programs/server/npm/npm-bcrypt/node_modules/bcrypt/node_modules/bindings/bindings.js:74:15)
at Object.<anonymous> (/home/hiapp/bundle/programs/server/npm/npm-bcrypt/node_modules/bcrypt/bcrypt.js:1:97)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
Through some research, it seems that the issue is that bcrypt is platform-specific, and because my development is on OS X 10.10, but my production server is on Ubuntu 14.04, there-in lies the problem. My work around was to run npm install bcrypt from the programs/server folder, then copy that from programs/server/node_modules/bcrypt to programs/server/npm. This seems like a lot of manual steps.
I am just about to re-deploy my app with some fixes, and I am worried that I am going to have to again perform the same steps. Is there a better way to deploy a Meteor app where you do not run into this issue? My procedure currently is:
Run meteor build
scp resulting tarball to my server (Digital Ocean)
explode the tarball in my app users home directory
ADDED STEPS: recompile bcrypt and copy the directory over as stated above
I am guessing the auto-refresh will be broken as the first time the server tries to load the new libraries it will explode in fiery glory. Would it be better to simply clone the GIT repo on the server and do the build straight from there, or can I use mup or any other tools to help smoothen the deployment process?
There are two ways of getting around this time-consuming problem which are totally dependant on how you deploy.
Manual deploy
If you are manually deploying your app then make sure that you are using node v0.10.361 and only that. Meteor does not work well with node v0.12.x. More specifically, the fibers module causes a lot of problems, it chokes on various errors2.
The following is the procedure that fixed it for me3, 4:
Remove the bcrypt module from the npm directory:
$ cd path_to_your_app/bundle/programs/server
$ rm -rf npm/npm-bcrypt/node_modules/bcrypt/
Install the bcrypt module into the node_modules directory first. This builds bcrypt against the server's OS:
$ npm install bcrypt
Move the newly created bcrypt module into the npm directory:
$ cp -r node_modules/bcrypt npm/npm-bcrypt/node_modules/bcrypt
Finally, restart the app, mogodb and any web server processes such as nginx6, through upstart if you have it configured. Under the heading sanity steps below you can perform if the steps outlined above have not fixed it for you.
Using Meteor Up (mup)
If you are using mup then the process is much easier as other answers on this thread point out. However, there are cases where errors still arise including the invalid ELF header error. Make sure you have the most recent version of mup npm update mup -g.
The first step is to remove any pre-existing app and nodejs package. Mup installs the app into /opt/ and within there you can find your_app and nodejs. Remove them.
Verify that you have the correct node version, 0.10.36 only1 and the following settings, in the mup.json file:
{
...
"setupMongo": true,
"setupNode": true,
"nodeVersion" : "0.10.36",
"setupPhantom": true,
"enableUploadProgressBar": true,
// Application name (No spaces)
"appName": "your_app",
// Location of app (local directory)
"app": ".",
...
}
Run:
$ mup setup
$ mup deploy
Navigate to the server folder on your server and rebuild modules:
$ cd /opt/your_app/app/programs/server
$ npm rebuild
$ npm install
Optional: $ sudo npm update node-gyp -g
Finally, restart the app, mogodb and any web server processes such as nginx6. After the above steps, you may want to look at sanity steps below for more debugging options.
Sanity steps
There are a few other steps you can perform:
Note that apache may also bind itself to the same port that nginx is running on. Look at your app's error logs and your web server's error logs to see if there are any issues. Stop apache via sudo service apache2 stop or brute force close (not recommended) any running processes on port 80.
Then remove or move the apache2 conf file to prevent it from starting up again. All conf files are located in /etc/init or /etc/init.d.
Use $ mup logs -f to view mup logs. To view errors from your app, the end of the file, /var/log/upstart/your_app.log is useful (assuming you have upstart configured).
If using nginx make sure your directories are symlinked.
$ ln -s /etc/nginx/sites-available/your_server_config /etc/nginx/sites-enabled/your_server_config
Moreover, make sure that you have specified a default_server5 in your_server_config.
Check that mongodb can run.
References
Meteor version 1.0.4.1 (released near the end of March 2015) requires that node version 0.10.36 be installed. I recommend using the node version manager, n, to control what version of node is running on your server at any one time. Link.
The dreaded [XXX.XX.XXX.XX] Error: '/opt/your_app/programs/server/node_modules/fibers/bin/linux-x64-v8-3.28/fibers.node' is missing. Try reinstalling 'node-fibers'? error. Link.
The procedure is modified from here: Link.
For your information, I used DigitalOcean's very helpful guide on deploying a meteor app to a server. Link.
Specifying a default_server. Link.
Common processes to restart are: sudo service mongod/nginx/yourapp restart.
I had the exact same issue - I switched to using Meteor Up (MUP) instead and the problem went away. Not to mention its a lot more straightforward!
I followed this tutorial on youtube - https://www.youtube.com/watch?v=WLGdXtZMmiI which covers deploying using MUP to Digital Ocean.
MUP's github page specifically mentions that it handles binary NPM modules - https://github.com/arunoda/meteor-up#binary-npm-module-support
Hope that's some help!
Running npm rebuild at bundle/programs/server/npm/ should take care of rebuilding the modules for the server platform, regardless of the original app being bundled at Linux or MacOS.
I had the same issue and did the following to fix it:
Uninstall nodejs
sudo apt-get remove nodejs
Remove any remaining files
rm -rf ~/.nvm ~/.npm
sudo rm -rf /usr/bin/node /opt/nodejs /usr/lib/node_modules /usr/local/lib/node_modules
Upgrade node version from the default setting in mup.json
"nodeVersion": "0.10.33",
Run mup setup and deploy
mup setup
mup deploy