I started a new Firebase project with the CLI.
I'm using only Cloud functions and wanted to deploy some functions
but Im getting this error
functions# lint: `tslint --project tsconfig.json`
I already changed following lines:
"npm --prefix \"$RESOURCE_DIR\" run lint",
"npm --prefix \"$RESOURCE_DIR\" run build"
to
"npm --prefix \"%RESOURCE_DIR%\" run lint",
"npm --prefix \"%RESOURCE_DIR%\" run build"
because they also threw an error.
What do I need to change?
Edit:
I created a new Firebase project (In a folder called Firebase) with the cli and only use Cloud functions.
Then I copied all my .ts files into the src folder and added my dependencies.
"firebase-admin": "~5.12.1",
"firebase-functions": "^1.0.3",
"#types/async": "^2.0.48",
"#types/camelcase": "^4.1.0",
"#types/glob": "^5.0.35",
"#types/request": "^2.47.0",
"#types/xml2js": "^0.4.2",
"async": "^2.6.0",
"camelcase": "^4.1.0",
"glob": "^7.1.2",
"install": "0.10.4",
"npm": "5.6.0",
"request": "^2.85.0",
"xml2js": "^0.4.19"
Then I run firebase deploy and got the following:
i deploying functions
Running command: npm --prefix "$RESOURCE_DIR" run lint
npm ERR! path C:\...\Projects\Firebase\%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:\...\Projects\Firebase\%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:\...\AppData\Roaming\npm-cache\_logs\2018-06-19T20_48_36_986Z-debug.log
Error: functions predeploy error: Command terminated with non-zero exit code4294963238
C:\...\Projects\Firebase>
The log file showed:
0 info it worked if it ends with ok
1 verbose cli [ 'C:\\Program Files\\nodejs\\node.exe',
1 verbose cli 'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli '--prefix',
1 verbose cli '%RESOURCE_DIR%',
1 verbose cli 'run',
1 verbose cli 'lint' ]
2 info using npm#5.6.0
3 info using node#v8.9.4
4 verbose stack Error: ENOENT: no such file or directory, open 'C:\...\Projects\Firebase\%RESOURCE_DIR%\package.json'
5 verbose cwd C:\...\Projects\Firebase
6 verbose Windows_NT 10.0.17134
7 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "--prefix" "%RESOURCE_DIR%" "run" "lint"
8 verbose node v8.9.4
9 verbose npm v5.6.0
10 error path C:\...\Projects\Firebase\%RESOURCE_DIR%\package.json
11 error code ENOENT
12 error errno -4058
13 error syscall open
14 error enoent ENOENT: no such file or directory, open 'C:\...\Projects\Firebase\%RESOURCE_DIR%\package.json'
15 error enoent This is related to npm not being able to find a file.
16 verbose exit [ -4058, true ]
I just edited the directory paths where necessary.
So I created another new project which uses hosting and functions.
I got the same error as above. After searching again I found this solution.
In the firebase.json file I replaced
"functions": {
"predeploy": [
"npm --prefix \"$RESOURCE_DIR\" run lint",
"npm --prefix \"$RESOURCE_DIR\" run build"
]
},
with
"functions": {
"predeploy": [
"npm --prefix \"%RESOURCE_DIR%\" run lint",
"npm --prefix \"%RESOURCE_DIR%\" run build"
]
}
After reading this issues on Github
What it worked for me was delete node_modules from 'functions' folder and then install everything again. I think I should have tried this first instead of something else. Of course, make sure you have tslint dependency installed.
reinitialize firebase in your project
firebase init
Related
The error
code: 'ENOENT',
errno: 'ENOENT',
syscall: 'spawn npm --prefix "D:\\Project\\Web\\functions" run lint',
path: 'npm --prefix "D:\\Project\\Web\\functions" run lint',
spawnargs: []
}
Error: functions predeploy error: Command terminated with non-zero exit code1
firebase.json
{
"firestore": {
"rules": "firestore.rules",
"indexes": "firestore.indexes.json"
},
"functions": {
"predeploy": [
"npm --prefix \"%RESOURCE_DIR%\" run lint"
]
}
}
I got the above error when I trying run the firebase deploy command, I searched the whole internet and I find related issues but not helpful so what is the problem?
I'm using Windows 10
Edit
Removing predeploy from firebase.json will solve the issue. Remove “npm --prefix "%RESOURCE_DIR%" run lint” as shown below.
firebase.json
"predeploy": [
"npm --prefix "%RESOURCE_DIR%" run lint"
]
In some cases, the issue could be due to unsupported node versions. As per official documentation Node.js 8 is deprecated. Make sure you are using supported versions.
Every time I enter the command in Visaul studio "firebase deploy --only functions".
VisualSTD shows me this error message
"The command "eslint." is either misspelled or
could not be found."
I want to connect firebase to my app and I get this error every time. I do not know what is wrong have already included all other functions with
{
"name": "functions",
"description": "Cloud Functions for Firebase",
"scripts": {
"lint": "eslint.",
"serve": "firebase emulators:start --only functions",
"shell": "firebase functions:shell",
"start": "npm run shell",
"deploy": "firebase deploy --only functions",
"logs": "firebase functions:log"
},
"engines": {
"node": "12"
},
"main": "index.js",
"dependencies": {
"nodemailer": "6.4.17",
"firebase-admin": "^9.2.0",
"firebase-functions": "^3.11.0"
},
"devDependencies": {
"eslint": "^7.6.0",
"eslint-config-google": "^0.14.0",
"firebase-functions-test": "^0.2.0"
},
"private": true
}
and this is what I get in the Console
The command "eslint." is either misspelled or
could not be found.
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\samo1\AppData\Roaming\npm-cache\_logs\2021-01-28T15_12_42_887Z-debug.log
events.js:292
throw er; // Unhandled 'error' event
^
Error: spawn npm --prefix "%RESOURCE_DIR%" run lint ENOENT
at notFoundError (C:\Users\samo1\AppData\Roaming\npm\node_modules\firebase-tools\node_modules\cross-env\node_modules\cross-spawn\lib\enoent.js:6:26)
at verifyENOENT (C:\Users\samo1\AppData\Roaming\npm\node_modules\firebase-tools\node_modules\cross-env\node_modules\cross-spawn\lib\enoent.js:40:16)
at ChildProcess.cp.emit (C:\Users\samo1\AppData\Roaming\npm\node_modules\firebase-tools\node_modules\cross-env\node_modules\cross-spawn\lib\enoent.js:27:25)
at Process.ChildProcess._handle.onexit (internal/child_process.js:277:12)
Emitted 'error' event on ChildProcess instance at:
at Process.ChildProcess._handle.onexit (internal/child_process.js:277:12) {
code: 'ENOENT',
errno: 'ENOENT',
syscall: 'spawn npm --prefix "%RESOURCE_DIR%" run lint',
path: 'npm --prefix "%RESOURCE_DIR%" run lint',
spawnargs: []
}
Try to install eslint-cli globally first
npm -g i eslint-cli
Then in your project folder
npm i eslint --save-dev
I'm attempting to setup a CI for build and deployment of my website through GitLab. My website is hosted on Firebase.
I've setup a subdomain for testing so it doesn't interfere with the production site.
I'm able to use the command firebase deploy --only hosting:test --message "Release: $PACKAGE_VERSION" on my local machine with no issue.
When I change it to firebase deploy --token $FIREBASE_TOKEN --only hosting:test --message "Release: $PACKAGE_VERSION" it gives me a Too many arguments error when running through the CI.
How can I get this to work?
Firebase-tools in my dev dependencies is at v6.6.0
Error message:
> firebase deploy --token $FIREBASE_TOKEN --only hosting:test --message 'Version: $npm_package_version'
Error: Too many arguments. Run firebase help deploy for usage instructions
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! admiralfeb-net#2019.3.1 deploy-test: `firebase deploy --token $FIREBASE_TOKEN --only hosting:test --message 'Version: $npm_package_version'`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the admiralfeb-net#2019.3.1 deploy-test 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! /root/.npm/_logs/2019-04-18T03_06_22_853Z-debug.log
ERROR: Job failed: exit code 1
My package.json scripts
"scripts": {
"ng": "ng",
"start": "ng serve --host 0.0.0.0",
"build": "ng build",
"build-prod": "ng build --prod --aot",
"test": "ng test --watch=true",
"test-ci": "ng test --no-watch --no-progress --browsers=ChromeHeadlessNoSandbox",
"e2e-ci": "ng e2e --protractor-config=e2e/protractor-ci.conf.js",
"lint": "ng lint",
"e2e": "ng e2e",
"deploy-test": "firebase deploy --token $FIREBASE_TOKEN --only hosting:test --message 'Version: $npm_package_version'",
"deploy-prod": "firebase deploy --token $FIREBASE_TOKEN --only hosting:prod --message 'Version: $npm_package_version'"
},
My gitlab-ci.yml:
image: node:latest
stages:
- install
- build
- deploy-test
- deploy-prod
install-dependencies:
stage: install
cache:
policy: push
paths:
- node_modules/
script:
- npm install --quiet
only:
changes:
- package.json
build:
stage: build
cache:
policy: pull
paths:
- node_modules/
script:
- npm run build-prod
artifacts:
expire_in: 1 week
paths:
- dist/
deploy-test:
stage: deploy-test
environment:
name: test
url: $FIREBASE_URL_TEST
when: manual
dependencies:
- build
cache:
policy: pull
paths:
- node_modules/
script:
- npm run deploy-test
deploy-prod:
stage: deploy-prod
environment:
name: production
url: $FIREBASE_URL_PROD
only:
- master
when: manual
dependencies:
- build
cache:
policy: pull
paths:
- node_modules/
script:
- npm run deploy-prod
My firebase.json
{
"hosting": [{
"target": "prod",
"public": "dist/admiralfeb-net",
"ignore": [
"firebase.json",
"**/.*",
"**/node_modules/**"
],
"rewrites": [
{
"source": "**",
"destination": "/index.html"
}
]
},
{
"target": "test",
"public": "dist/admiralfeb-net",
"ignore": [
"firebase.json",
"**/.*",
"**/node_modules/**"
],
"rewrites": [
{
"source": "**",
"destination": "/index.html"
}
]
}]
}
and my .firebaserc
{
"projects": {
"default": "admiralfebnet"
},
"targets": {
"admiralfebnet": {
"hosting": {
"test": [
"test-admiralfeb"
],
"prod": [
"admiralfebnet"
]
}
}
}
}
After fighting with this for a day or two, I figured out what was incorrect.
In gitlab, there's a protected option for your env variables. This will hide them from pipelines not running on a protected tag or branch. I had this option checked.
Unchecked the protected option and reran the pipeline. I also removed the --token variable from the deploy call. Firebase will use the token if it's in the environment and called FIREBASE_TOKEN.
I have Flow setup per the instructions. My package.json:
{
[…],
"devDependencies": {
"flow-bin": "^0.82.0"
},
"dependencies": {
[…]
},
"scripts": {
"start": "react-scripts start",
"build": "babel",
"prepublish": "npm run build",
"flow": "flow",
}
}
When I run npm run-script flow I get what I expect from flow, plus an error:
Error
------------------------------------------------------------------------------------- src/reducers/brands.js:65:67
Cannot resolve name `action`.
65| export function brandReducer(state: BrandState = brandState, Action: action) {
Found 1 error
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! wsbc.vpn#0.1.0 flow: `flow`
npm ERR! Exit status 2
Why am I seeing this errno 2? Because flow found a type error and returned that status?
Also, flow does not run with each recompile when running my application as npm start as usual. Is it possible to make this happen once the flow server is started in the background?
Is there something wrong with my setup?
It this the first time that this happend to me. I've tried to init firebase more than once, but still having the same results.
When I try to deploy functions with command:
firebase deploy --only functions
The console returns next:
=== Deploying to 'hay-equipo-3a19b'...
i deploying functions
Running command: npm --prefix functions run build
npm ERR! missing script: build
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Usuario\AppData\Roaming\npm-cache\_logs\2018-01-24T21_36_36_260Z-debug.log
Error: functions predeploy error: Command terminated with non-zero exit code1
Here is my package.json of functions folder
{
"name": "functions",
"description": "Cloud Functions for Firebase",
"scripts": {
"serve": "firebase serve --only functions",
"shell": "firebase experimental:functions:shell",
"start": "npm run shell",
"deploy": "firebase deploy --only functions",
"logs": "firebase functions:log"
},
"dependencies": {
"firebase-admin": "~5.8.1",
"firebase-functions": "^0.8.1",
"nodemailer": "^4.4.2"
},
"private": true
}
The log file says
0 info it worked if it ends with ok
1 verbose cli [ 'C:\\Program Files\\nodejs\\node.exe',
1 verbose cli 'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli '--prefix',
1 verbose cli 'functions',
1 verbose cli 'run',
1 verbose cli 'build' ]
2 info using npm#5.5.1
3 info using node#v8.9.3
4 verbose stack Error: missing script: build
4 verbose stack at run (C:\Program Files\nodejs\node_modules\npm\lib\run-script.js:151:19)
4 verbose stack at C:\Program Files\nodejs\node_modules\npm\lib\run-script.js:61:5
4 verbose stack at C:\Program Files\nodejs\node_modules\npm\node_modules\read-package-json\read-json.js:115:5
4 verbose stack at C:\Program Files\nodejs\node_modules\npm\node_modules\read-package-json\read-json.js:402:5
4 verbose stack at checkBinReferences_ (C:\Program Files\nodejs\node_modules\npm\node_modules\read-package-json\read-json.js:357:45)
4 verbose stack at final (C:\Program Files\nodejs\node_modules\npm\node_modules\read-package-json\read-json.js:400:3)
4 verbose stack at then (C:\Program Files\nodejs\node_modules\npm\node_modules\read-package-json\read-json.js:160:5)
4 verbose stack at ReadFileContext.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\read-package-json\read-json.js:332:20)
4 verbose stack at ReadFileContext.callback (C:\Program Files\nodejs\node_modules\npm\node_modules\graceful-fs\graceful-fs.js:78:16)
4 verbose stack at FSReqWrap.readFileAfterOpen [as oncomplete] (fs.js:420:13)
5 verbose cwd C:\Users\Usuario\Projects\torneos-club-oeste
6 verbose Windows_NT 10.0.16299
7 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "--prefix" "functions" "run" "build"
8 verbose node v8.9.3
9 verbose npm v5.5.1
10 error missing script: build
11 verbose exit [ 1, true ]
Seems if you just put a blank "build" entry into your functions/package.json file under 'scripts' then it solves this (well it did for me).
{
"scripts": {
"build": "", <----- simply add this!
...
},
...
}