firebase deploy functions not working - firebase

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!
...
},
...
}

Related

Publishing React+dotnet core application using Github Actions throwing error MSB3073: The command "npm run build" exited with code 1

I am getting the below error while publishing the React+dotnet core application using Github Actions. I am using the GitHub self-hosted runners on my windows server 2016.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! ptrx_backoffice#0.1.0 build: `react-scripts build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the ptrx_backoffice#0.1.0 build 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\Administrator\AppData\Roaming\npm-cache\_logs\2021-02-11T15_54_47_880Z-debug.log
D:\aayush\ptrx_backoffice\ptrx_backoffice\PTRX_BackOffice.csproj(49,5): error MSB3073: The command "npm run build" exited with code 1.
Error: Process completed with exit code 1.
Logfile 2021-02-11T15_54_47_880Z-debug.log output is as below. I have tried deleting node-modules, cleaned cache using npm but it doesn't seem an issue with NPM as it's clearly saying in the logs that this is not related to NPM. Please let me know if someone can help on it.
0 info it worked if it ends with ok
1 verbose cli [
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 'run',
1 verbose cli 'build'
1 verbose cli ]
2 info using npm#6.13.4
3 info using node#v12.16.0
4 verbose run-script [ 'prebuild', 'build', 'postbuild' ]
5 info lifecycle ptrx_backoffice#0.1.0~prebuild: ptrx_backoffice#0.1.0
6 info lifecycle ptrx_backoffice#0.1.0~build: ptrx_backoffice#0.1.0
7 verbose lifecycle ptrx_backoffice#0.1.0~build: unsafe-perm in lifecycle true
8 verbose lifecycle ptrx_backoffice#0.1.0~build: PATH: C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin;D:\aayush\ptrx_backoffice\ptrx_backoffice\ClientApp\node_modules\.bin;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\Program Files (x86)\PHP\v7.1;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\;C:\Program Files\Microsoft SQL Server\100\Tools\Binn\;C:\Program Files\Microsoft SQL Server\100\DTS\Binn\;C:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\VSShell\Common7\IDE\;C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\IDE\PrivateAssemblies\;C:\Program Files (x86)\Microsoft SQL Server\100\DTS\Binn\;C:\Program Files\Microsoft\Web Platform Installer\;C:\Program Files\dotnet\;C:\Program Files (x86)\dotnet\;C:\Users\Administrator\AppData\Roaming\npm;C:\Program Files\Microsoft SQL Server\120\DTS\Binn\;C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\110\Tools\Binn\;C:\Program Files (x86)\Microsoft SQL Server\120\Tools\Binn\;C:\Program Files\Microsoft SQL Server\120\Tools\Binn\;C:\Program Files (x86)\Microsoft SQL Server\120\Tools\Binn\ManagementStudio\;C:\Program Files (x86)\Microsoft SQL Server\120\DTS\Binn\;C:\Program Files\Git\cmd;C:\Program Files\nodejs\;C:\Apache24\bin;C:\Users\Administrator\.dnx\bin;C:\Program Files\Microsoft DNX\Dnvm\;C:\Program Files\Microsoft SQL Server\130\Tools\Binn\;C:\Program Files\PuTTY\;C:\python\Scripts\;C:\python\;C:\Program Files\Scripts\;C:\Program Files\;C:\Users\Administrator\AppData\Roaming\npm;C:\Apache24\bin;C:\Program Files\JetBrains\PyCharm Community Edition 2020.1\bin;;C:\Users\Administrator\.dotnet\tools
9 verbose lifecycle ptrx_backoffice#0.1.0~build: CWD: D:\aayush\ptrx_backoffice\ptrx_backoffice\ClientApp
10 silly lifecycle ptrx_backoffice#0.1.0~build: Args: [ '/d /s /c', 'react-scripts build' ]
11 silly lifecycle ptrx_backoffice#0.1.0~build: Returned: code: 1 signal: null
12 info lifecycle ptrx_backoffice#0.1.0~build: Failed to exec build script
13 verbose stack Error: ptrx_backoffice#0.1.0 build: `react-scripts build`
13 verbose stack Exit status 1
13 verbose stack at EventEmitter.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\index.js:332:16)
13 verbose stack at EventEmitter.emit (events.js:321:20)
13 verbose stack at ChildProcess.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\lib\spawn.js:55:14)
13 verbose stack at ChildProcess.emit (events.js:321:20)
13 verbose stack at maybeClose (internal/child_process.js:1021:16)
13 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5)
14 verbose pkgid ptrx_backoffice#0.1.0
15 verbose cwd D:\aayush\ptrx_backoffice\ptrx_backoffice\ClientApp
16 verbose Windows_NT 6.3.9600
17 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run" "build"
18 verbose node v12.16.0
19 verbose npm v6.13.4
20 error code ELIFECYCLE
21 error errno 1
22 error ptrx_backoffice#0.1.0 build: `react-scripts build`
22 error Exit status 1
23 error Failed at the ptrx_backoffice#0.1.0 build script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]
According tho this link:
https://social.msdn.microsoft.com/Forums/vstudio/en-US/f70c2425-14de-49cf-b228-d29548c9ef87/getting-error-msb3073?forum=msbuild
You may have a wrong path set somewhere, just to quote the article:
Generally speaking, the Error MSB3073 is generally caused by an incorrect path in the command line.
Now, in your PATH you have, in particular, this value:
D:\aayush\ptrx_backoffice\ptrx_backoffice\ClientApp\node_modules\.bin;
But, and this is where the issue seems to be, you call this command:
C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run" "build"
It looks that you are trying to execute a binary that does not exists.
My feeling is that you are using a development environment variable in your production environment.

firebase tells me that the command "eslint." is either misspelled or could not be found

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

How to deploy to specific Firebase hosting service via CI? Getting "Too many arguments" error

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.

Can't get Flow to run with each babel recompile

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?

Firebase Cloud Function deploy tslint error

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

Resources