I was having issues with firebase deploy command recently. After firebase deploy command all others were being deployed except firebase (storage, database etc) So I decided to reinstall firebase to fix this situation but after reinstall my problem got bigger. Now none of them are deployed with the following error:
i deploying database, functions
Running command: npm --prefix $RESOURCE_DIR run lint
npm ERR! path C:\Users\faruk\Google Drive\Android\firebase\1\$RESOURCE_DIR\package.json
npm ERR! code ENOENT
npm ERR! errno -4058
npm ERR! syscall open
npm ERR! enoent ENOENT: no such file or directory, open 'C:\Users\faruk\Google Drive\Android\firebase\1\$RESOURCE_DIR\package.json'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\faruk\AppData\Roaming\npm-cache\_logs\2018-01-24T18_21_34_878Z-debug.log
Error: functions predeploy error: Command terminated with non-zero exit code4294963238
After a bit research, I saw some topics about this which advice to change
$RESOURCE_DIR to %RESOURCE_DIR%
in windows systems (I am using windows 10 btw). So, I edited my firebase.json file which is in one upper level of my functions folder. like this. (I don't know if this is the right file that I should edit)
"database": {
"rules": "database.rules.json"
},
"functions": {
"predeploy": [
"npm --prefix %RESOURCE_DIR% run lint"
]
}
}
but after this edit, I started to get another error message like this.
i deploying database, functions
Running command: npm --prefix %RESOURCE_DIR% run lint
Usage: npm <command>
where <command> is one of:
access, adduser, bin, bugs, c, cache, completion, config,
ddp, dedupe, deprecate, dist-tag, docs, doctor, edit,
explore, get, help, help-search, i, init, install,
install-test, it, link, list, ln, login, logout, ls,
outdated, owner, pack, ping, prefix, profile, prune,
publish, rb, rebuild, repo, restart, root, run, run-script,
s, se, search, set, shrinkwrap, star, stars, start, stop, t,
team, test, token, tst, un, uninstall, unpublish, unstar,
up, update, v, version, view, whoami
npm <command> -h quick help on <command>
npm -l display full usage info
npm help <term> search for help on <term>
npm help npm involved overview
Specify configs in the ini-formatted file:
C:\Users\faruk\.npmrc
or on the command line via: npm <command> --key value
Config info can be viewed via: npm help config
npm#5.6.0 C:\Program Files\nodejs\node_modules\npm
Error: functions predeploy error: Command terminated with non-zero exit code1
Any advice is appreciated. Thanks in advance.
The error stems from the fact that you have a space somewhere in the path of your project ("Google Drive"):
C:\Users\faruk\Google Drive\Android\firebase\1\$RESOURCE_DIR\package.json
Unfortunately, this is confusing the npm command line, and it's taking that as two arguments separated by that space.
Normally, I would expect to be able to place quotes around the whole thing to keep the space from being interpreted that way. So I tried this:
"predeploy": [
"npm --prefix \"%RESOURCE_DIR%\" run lint"
]
And it works for me.
I'll follow up with the Firebase team internally about this issue, as well as the fact that changes need to be made for Windows.
What happens actually is that in Windows, firebase.json contains the following by default:
"predeploy": [
"npm --prefix \"$RESOURCE_DIR\" run lint"
]
Modify it to:
"predeploy": [
"npm --prefix \"%RESOURCE_DIR%\" run lint"
]
It worked for me, hope it works for you.
"predeploy": [
"npm --prefix \"$RESOURCE_DIR\" run lint"
]
I remove that on firebase.json finally, it started to deploy again
For me, none of the above worked. Initially, on a fresh firebase-function install, I was getting error on non-zero exit code2. so I removed the functions directory, re-installed, but on the functions directory configuration step, I chose to say "no" to the add-lint step.
once I chose to not include lint, I got error non-zero exit code1.
from there checked my firebase.json file and looked at the predeploy script. because the deployment process was failing at this point, it was where I started. my firebase.json file looked like this:
{
"functions": {
"predeploy": [ "npm --prefix \"$RESOURCE_DIR\" run lint" ]
}
}
for some reason I intuitively thought to remove the lint in the predeploy script. this fixed everything. Im on MacOS by the way..
This what work for me after change $RESOURCE_DIR to %RESOURCE_DIR% in firebase.json
{
"functions": {
"predeploy": [
"npm --prefix \"%RESOURCE_DIR%\" run lint",
"npm --prefix \"%RESOURCE_DIR%\" run build"
]
}
}
type this into your console ' firebase deploy --only hosting'. It worked for me
Try running npm install inside the functions folder of the project.
Maybe you are importing one or more node modules in index.ts that isn't installed, in this case you need to install it by running like:
npm install <somemodule> --save
I had the same problem in Windows. What I did was I copied all the files which were in functions folder and passed it to %RESOURCE_DIR% folder and then I run the Firebase deploy and it deployed successfully.
I fixed it: you must pay attention at another place
Do you see the error description
$ firebase deploy --only functions
=== Deploying to 'fix-firebase-functions'...
i deploying functions
Running command: npm --prefix "$RESOURCE_DIR" run lint
> functions# lint C:\Users\vuduc\OneDrive\Tài liệu\Code tutotial practice\test\functions
> eslint .
C:\Users\vuduc\OneDrive\Tài liệu\Code tutotial practice\test\functions\index.js
37:16 warning Avoid nesting promises promise/no-nesting
42:13 error Expected catch() or return promise/catch-or-return
42:13 warning Avoid nesting promises promise/no-nesting
42:31 error Each then() should return a value or throw promise/always-return
✖ 4 problems (2 errors, 2 warnings)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! functions# lint: `eslint .`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the functions# lint script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\vuduc\AppData\Roaming\npm-cache\_logs\2020-06-01T14_38_16_060Z-debug.log
events.js:287
throw er; // Unhandled 'error' event
^
Error: spawn npm --prefix "%RESOURCE_DIR%" run lint ENOENT
at notFoundError (C:\Users\vuduc\AppData\Local\Yarn\Data\global\node_modules\cross-env\node_modules\cross-spawn\lib\enoent.js:6:26)
at verifyENOENT (C:\Users\vuduc\AppData\Local\Yarn\Data\global\node_modules\cross-env\node_modules\cross-spawn\lib\enoent.js:40:16)
at ChildProcess.cp.emit (C:\Users\vuduc\AppData\Local\Yarn\Data\global\node_modules\cross-env\node_modules\cross-spawn\lib\enoent.js:27:25)
at Process.ChildProcess._handle.onexit (internal/child_process.js:275:12)
Emitted 'error' event on ChildProcess instance at:
at ChildProcess.cp.emit (C:\Users\vuduc\AppData\Local\Yarn\Data\global\node_modules\cross-env\node_modules\cross-spawn\lib\enoent.js:30:37)
at Process.ChildProcess._handle.onexit (internal/child_process.js:275:12)
code: 'ENOENT',
errno: 'ENOENT',
syscall: 'spawn npm --prefix "%RESOURCE_DIR%" run lint',
path: 'npm --prefix "%RESOURCE_DIR%" run lint',
spawnargs: []
Error: functions predeploy error: Command terminated with non-zero exit code1
error deploy cloud functions
You need to scroll up to see the error description, the line
functions predeploy error: Command terminated with non-zero exit code1
is just a general description that there is an error to fix before deploying.
This is what really needs attention, which instructions do you need to fix?
✖ 4 problems (2 errors, 2 warnings)
Pay attention here
This fixed it for me:
Go to "firebase.json" file in the root directory of the project
Remove everything inside "predeploy" in firebase.json, and it'll stop running the script which is causing issues.
"redeploy": [
"npm --prefix \"%RESOURCE_DIR%\" run lint"
]
Use redeploy instead predeploy
For me, the issue was (I presume) because firebase couldn't find the script.
Didn't work:
{
"hosting": {
"predeploy": "predeploy.sh",
...
}
Running command: predeploy.sh
events.js:160
throw er; // Unhandled 'error' event
^
Error: spawn predeploy.sh ENOENT
at exports._errnoException (util.js:1020:11)
at Process.ChildProcess._handle.onexit (internal/child_process.js:193:32)
at onErrorNT (internal/child_process.js:367:16)
at _combinedTickCallback (internal/process/next_tick.js:80:11)
at process._tickCallback (internal/process/next_tick.js:104:9)
at Module.runMain (module.js:606:11)
at run (bootstrap_node.js:389:7)
at startup (bootstrap_node.js:149:9)
at bootstrap_node.js:504:3
Error: hosting predeploy error: Command terminated with non-zero exit code1
Did work: (note the ./)
{
"hosting": {
"predeploy": "./predeploy.sh",
...
}
When Using VS code ,open folder of Firecast (this helps open firebase.json of Resource Directory ) In firebase.json change the code of file to this:
{
"functions": {
"predeploy": [
"npm --prefix \"%RESOURCE_DIR%\" run lint",
"npm --prefix \"%RESOURCE_DIR%\" run build"
]
}
}
In my case I created a function to print logs, something like this:
function log(tag: string, value: any) {
console.log(tag, JSON.stringify(value));
}
When I add async in front of it, it starts exploding the build :)
I solve this by re-initiating firebase init, then not selecting to use eslint. Deploy worked after that.
This can also happen if you dont choose a blaze plan from firebase. basically deployment of cloud functions require a blaze plan activated
I'm on mac and since I moved my firebase project to another directory/laptop, I had this exact issue.
I resolved my issue by just re-initializing my firebase project.
firebase init
Be careful though. Since most of your files already exist, it might want to override them. Just say no to all override questions. Unless of course all your code is pushed to the firebase console ... which it should be 😋
"predeploy": [ "npm --prefix \"$RESOURCE_DIR\" run lint" ]
I remove that on firebase.json finally, it works for me.
Related
This is the error log. And I cannot for the life of me fix this. everything works fine in dev but on deployment it fails. :(
23:12:53.687 Failed to compile.
23:12:53.687 ModuleNotFoundError: Module not found: Error: Can't resolve '../../styles/Homebody.module.css' in '/vercel/workpath0/components/Home'
23:12:53.687 > Build error occurred
23:12:53.688 Error: > Build failed because of webpack errors
23:12:53.688 at /vercel/workpath0/node_modules/next/dist/build/index.js:15:918
23:12:53.689 at runMicrotasks (<anonymous>)
23:12:53.689 at processTicksAndRejections (internal/process/task_queues.js:93:5)
23:12:53.689 at async /vercel/workpath0/node_modules/next/dist/build/tracer.js:3:470
23:12:53.704 npm ERR! code ELIFECYCLE
23:12:53.704 npm ERR! errno 1
23:12:53.707 npm ERR! next_front#0.1.0 build: `next build && next export`
23:12:53.707 npm ERR! Exit status 1
23:12:53.707 npm ERR!
23:12:53.707 npm ERR! Failed at the next_front#0.1.0 build script.
23:12:53.707 npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
23:12:53.714 npm ERR! A complete log of this run can be found in:
23:12:53.714 npm ERR! /vercel/.npm/_logs/2021-02-24T23_12_53_708Z-debug.log
23:12:53.719 Error: Command "npm run build" exited with 1
One thing is to start all .module.css files with a capital letter. Sometimes. however, you will still get the same error. To make matters worse, the error keeps occurring for varying .module.css files. So sometimes you will get A.module.css not found, and another time you get B.module.css not found.
I then deleted node_modules and ran npm i. No result; same error.
What did work for me was to make a new project with:
yarn create next-app
…and then add all the files from the old module one by one while redeploying the app each time to check it still works.
This isn't elegant, but it's fast enough and it does the trick.
This is an old question but I hope I can help someone in the future!
I was able to solve this issue by moving my CSS module file out of a subfolder into the root Styles folder.
Before:
-Styles
--Pages
---FileName.module.css
After:
-Styles
--FileName.module.css
functions: package.json indicates an outdated version of firebase-functions.
Please upgrade using npm install --save firebase-functions#latest in your functions directory.
=== Deploying to 'zootopia-mysite'...
i deploying functions, hosting
Running command: npm --prefix "$RESOURCE_DIR" run lint
> functions# lint /Users/zootopia/functions
> eslint .
✔ functions: Finished running predeploy script.
Error: There was an error reading functions/package.json:
Engines field is required but was not found in functions/package.json.
To fix this, add the following lines to your package.json:
"engines": {
"node": "10"
}
I've also tried to upgrade with npm install --save firebase-functions#latest and it still gives me the same error.
Your local project apparently works with both Firebase Hosting and Cloud Functions. The error message is telling you that the Cloud Functions deployment is failing, which doesn't have anything do with Firebase Hosting yet.
If you are trying to follow the advice of the output here, you're going to have to change to the "functions" folder and run the npm commands to upgrade the old modules and make any other changes to package.json.
I've followed all the steps in here to get the "Classy Taxi: Google Play Billing Subscriptions Android App Java Sample" running, however on the last step I'm very confused, it´s not clear to me as to how I´m supposed to deploy the back-end, here are the steps:
These are steps to build the backend server code located here
Make sure you have installed Node.js, npm, and Firebase CLI.
Run npm install to install dependencies.
Configure Cloud Functions for Firebase with your Android app and subscription products:
firebase use --add {your_firebase_project_id}
firebase functions:config:set app.package_name="your_android_application_id"
firebase functions:config:set app.basic_plan_sku="your_basic_subscription_product_sku_id"
firebase functions:config:set app.premium_plan_sku="your_premium_subscription_product_sku_id"
Run firebase deploy to deploy your backend to Cloud Functions for Firebase.
On the steps it´s not clear as to how the server will be deployed, it only mentioned the app id and the products SKU´s but not the code for the server so I need help clarifying that, please. I would like to see steps by step how to deploy the server.
This is what I´m currently doing:
1. Go to the root folder for the server
2. Open cmd from that folder
3. run the commands listed on the docs.
4. then I get this error:
=== Deploying to 'billing-project-c9f03'...
i deploying functions, hosting
Running command: npm --prefix "$RESOURCE_DIR" run lint
npm ERR! code ENOENT
npm ERR! syscall open
npm ERR! path C:\Users\frank\Desktop\Billing app\ClassyTaxiServer\server\package.json
npm ERR! errno -4058
npm ERR! enoent ENOENT: no such file or directory, open 'C:\Users\frank\Desktop\Billing app\ClassyTaxiServer\server\package.json'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\frank\AppData\Roaming\npm-cache\_logs\2020-04-13T01_21_30_198Z-debug.log
Error: functions predeploy error: Command terminated with non-zero exit code429496323
But I see the package.json file on the root folder.
See the Firebase CLI reference. This should be the project's root directory ClassyTaxiServer; assuming that you've ran all previous steps successfully, before attempting to firebase deploy. firebase.json knows what to do... however, that file is the actual problem; see PR #289.
Update firebase.json to this version and it should work out:
{
"functions": {
"predeploy": [
"npm --prefix \"$RESOURCE_DIR\" run lint",
"npm --prefix \"$RESOURCE_DIR\" run build"
],
"source": "."
},
"hosting": {
"public": "webapp",
"ignore": [
"firebase.json",
"**/.*",
"**/node_modules/**"
],
"rewrites": [ ]
}
}
This question already has answers here:
Cloud Functions deploy error during lint on Windows: "enoent ENOENT: no such file or directory"
(10 answers)
Closed 4 years ago.
I'm trying to deploy my cloud function firebase CLI, but there is an issue with my functions. I haven't changed any of my firebase cloud function settings. When I try to run firebase deploy --only functions, I get the following error:
npm ERR! errno -4058 npm ERR! syscall open npm ERR! enoent ENOENT: no
such file or directory, open
'F:\react\Fullstack-Hoffyevents-react-redux\event\%RESOURCE_DIR%\package.json'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent
npm ERR! A complete log of this run can be found in: npm ERR!
C:\Users\wasif\AppData\Roaming\npm-cache_logs\2018-11-07T14_41_19_766Z-debug.log
Error: functions predeploy error: Command terminated with non-zero
exit code4294963238
This is a common issue on windows users
Go to your function folder and open firebase.json file
inside you will see something like this
{
"functions": {
"predeploy": [
"npm --prefix \"$RESOURCE_DIR\" run lint"
]
}
}
change $RESOURCE_DIR with %RESOURCE_DIR% and that should work in your next deploy
you should have something like this
"functions": {
"predeploy": [
"npm --prefix \"%RESOURCE_DIR%\" run lint",
"npm --prefix \"%RESOURCE_DIR%\" run build"
]
}
Following the firebase function getting started guide and getting a seemingly simple error once trying to deploy with:
firebase deploy --only functions
i deploying functions
Running command: npm --prefix $RESOURCE_DIR run lint
npm ERR! path C:\Users\Beat\leginformant\$RESOURCE_DIR\package.json
npm ERR! code ENOENT
npm ERR! errno -4058
npm ERR! syscall open
npm ERR! enoent ENOENT: no such file or directory, open
'C:\Users\Beat\leginformant\$RESOURCE_DIR\package.json'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent
The package.json file does exist just as the tutorial shows in my project/functions/package.json.
Have tried changing or printing out the RESOURCE_DIR env with no success. Assuming it would be scoped inside of the NPM shell environment.
npm version: 5.6.0
node version: 8.9.0
This is a known problem with the Firebase CLI 3.17.0 through at least 3.17.3, but only on Windows. You can fix this on your machine by editing firebase.json at the root of your project and replacing $RESOURCE_DIR with %RESOURCE_DIR% in the npm commands you see there. The former is the unix syntax way to use an environment variable, whereas the latter is the Windows command shell syntax. Since you're using Windows, you need to use the Windows syntax.
The team is looking into ways to prevent having to make changes to the config files you use, as it's not really convenient for teams that works across platform to keep changing the same file back and forth.
EDIT: This issue should be fixed with projects created with CLI version 3.17.5.
When running
firebase init functions
I use this configuration
? What language would you like to use to write Cloud Functions? JavaScript
//TypeScript doesn't work
? Do you want to use ESLint to catch probable bugs and enforce style? Yes
//If you don't you will get a missing file lint
? File functions/package.json already exists. Overwrite? Yes
? Do you want to install dependencies with npm now? Yes
//Why not
Then if use windows
Replace $RESOURCE_DIR by %RESOURCE_DIR% in firebase.json
In windows, while Initializing the firebase Project in CLI using firebase init,In firebase.json file,Change the code to as per below{
"functions": {
"predeploy": [
"npm --prefix \"%RESOURCE_DIR%\" run lint"
],
"source": "functions"
}
}
After this change, try firebase deploy --only functions command.
Change the following:
npm --prefix \"$RESOURCE_DIR\" run lint
to
npm --prefix \"%RESOURCE_DIR%\" run lint
in firebase.json file in main structure
{
"functions": {
"predeploy": [
"npm --prefix \"%RESOURCE_DIR%\" run lint"
],
"source": "functions"
}
}
You can fix this by accessing your firebase.json file and delete this line containing RESOURCE_DIR.
Apart from the other suggestions, if you change the preflight/predeploy command from:
"npm --prefix \"$RESOURCE_DIR\" run lint", OR
"npm --prefix \"%RESOURCE_DIR%\" run lint"
to
"npm --prefix ./functions run lint"
the issue seems to get fixed. This also resolves it for both Windows and Linux.
To see more details, please see this answer (and further thread): https://github.com/firebase/firebase-tools/issues/610#issuecomment-360147507
You have to change firebase.json file as shown in here
"npm --prefix functions run lint"
"npm --prefix functions run build"
As an extra doing npm --prefix %RESOURCE_DIR% run lint like #Deji James said, made me some progress but still didn't work.
As a suggestion I found this
https://github.com/firebase/firebase-tools/issues/610
and #merlinnot says here
Hey guys, you all probably have sth in your predeploy in firebase.json, don't you? Just delete what you have there for now if it's not that important.
worked for me.
PS. before deciding to delete, I have done all reinstall things, uninstall things. Only this is worked.
For ubuntu you need to change firebase.json to following, notice $ before RESOURCE_DIR
{
"functions": {
"predeploy": [
"npm --prefix \"$RESOURCE_DIR\" run lint",
"npm --prefix \"$RESOURCE_DIR\" run build"
]
}
}
for Windows 10 you need to change firebase.jsonn to following, notice % after and before RESOURCE_DIR
{
"functions": {
"predeploy": [
"npm --prefix \"%RESOURCE_DIR%\" run lint",
"npm --prefix \"%RESOURCE_DIR%\" run build"
]
}
}
(for Windows no idea if it work in ios or not)Just delete everything under "Predeploy":
it should look like
"predeploy": [ ],
and this work for me hope it will solve your problem also
i find this solution here