iam trying to deploy my first cloud function on firebase but the problem is that it always says that there is something wrong and no files are matching the pattern i dont know why even that the index.ts is where it is supposed to be
the error code is
=== Deploying to 'mscmu-aeab1'...
i deploying functions
Running command: npm --prefix "$RESOURCE_DIR" run lint
> functions# lint C:\Users\fahmi\msc_mu\cloud_functions\functions
> eslint 'src/**/*'
Oops! Something went wrong! :(
ESLint: 7.9.0
No files matching the pattern "'src/**/*'" were found.
Please check for typing mistakes in the pattern.
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! functions# lint: `eslint 'src/**/*'`
npm ERR! Exit status 2
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\fahmi\AppData\Roaming\npm-cache\_logs\2020-09-26T22_01_33_578Z-debug.log
Error: functions predeploy error: Command terminated with non-zero exit code2
https://i.imgur.com/rb10Tsi.png
In your functions package.json edit the lint script as follows:
eslint --ext .ts src
This problem is solved in this commit.
In your functions folders open package.json and edit the line starting with lint like this:
"lint": "eslint \"src/**/*\""
This issue is resolved with the Firebase CLI version 8.12.0. The update is to escape quotes around the argument to eslint as shown in this commit.
Related
This is the log I'm getting on the pipeline, my team was using the <%= tag on an ejs file, and I had to make a change to use <%- and then the build does not works on gitlab ci, but when I try to build locally, it works. And I'm not using this "underscore" library mentioned in the error.
"build:prod": "cross-env NODE_ENV=production webpack"
This is the script to run the build
ERROR in ./views/forms/survey.ejs
Module not found: Error: Can't resolve 'underscore' in '/builds/ve/vsplatform/vsmanager/views/forms'
# ./views/forms/survey.ejs 1:0-21
# ./controllers/forms/surveyForm_controller.js
# ./initialization.js
# ./vsmanager.js
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! VSHOW_HTML_PLATFORM#1.0.0 build:prod: cross-env NODE_ENV=production webpack
npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the VSHOW_HTML_PLATFORM#1.0.0 build:prod 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/2022-08-25T16_22_43_830Z-debug.log
I figured it out, the problem is that I haven't installed underscore on the project, but I'm still trying to understand why it was working locally.
I got a new notebook, so I install all languages I use. I use nodejs v10.16.
I had an Angular code which I wanted to run on the new notebook. The version of the node was the same. However, when I wrote in the command line npm start, I got these message:
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! <my-project>-client#0.0.0 start: `ng serve`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the <my-project>-client#0.0.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
Why did it happend? I install node_modules before starting and it ran on my earlier notebook.
How should I solve this problem?
Make sure you're running the start script from the same location as your package.json file.
Check the format of package.json scripts object, ensuring the script name is correct and denoting where the script/object ends with a comma.
"scripts": {
"start": "react-scripts start"
},
Ensure the app/module your start script is calling is installed/installed correctly.
Use the full npm command to run your start script:
npm run start
If all else fails, rename your node_modules to node_modules_old, check your package.json file has all your required dependencies and run npm install from the same directory to generate a new node_modules folder before trying to run the script again with npm run start.
Why does Firebase show some weird errors? I haven’t had any dot (.) related error.
functions# build E:\deepak\function\functions
tslint --project tsconfig.json && ./node_modules/.bin/tsc
'.' is not recognized as an internal or external command,
operable program or batch file.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! functions# build: `tslint --project tsconfig.json && ./node_modules/.bin/tsc`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the functions# build script.
this is because you are triying to run the command on CMD, it doesn't recognize the current path with (./) replace the slashes for backslashes or put the full path (on windows style with backslashes)for example:
tslint --project tsconfig.json && .\node_modules.bin\tsc
This is because windows uses backslash for the paths
I am trying to setup a task in package.json
"scripts": {
"unit-test": "mocha './test/unit/**/*.spec.js'",
}
However when I run
npm run unit-test
the following errors are thrown in the console at the end of the run:
npm ERR! Darwin 16.6.0
npm ERR! argv "/Users/shreya.vakil/.nvm/v6.9.5/bin/node" "/Users/d.bubble/.nvm/v6.9.5/bin/npm" "run" "unit-test"
npm ERR! node v6.9.5
npm ERR! npm v3.10.10
npm ERR! code ELIFECYCLE
npm ERR! myapp#0.0.1-SNAPSHOT unit-test: `mocha './test/unit/**/*.spec.js'`
npm ERR! Exit status 1
However, if I change the command to
"scripts" : {
"unit-test": "mocha './test/unit/**/*.spec.js'; exit 0",
}
this error is not thrown. However, I am not sure if this is the right approach.
The original behavior is correct, if a little ugly - if your tests fail, Mocha returns an exit code of 1, which is technically an error. Your second example makes the output prettier, but it'll cause you issues if you try to integrate your build scripts into other tools (for example, Travis), as they won't be able to detect when your tests fail.
The best solution to this would be to get rid of the exit 0 and upgrade your version of NPM - the output was made much shorter in v4.6.1. You can do this by running the following command:
npm install npm -g
I am setting up my environment to lint ES6. I installed eslint and can see it in my node_modules. In my node_modules/bin directory, I have the command eslint.
I can run the command and point it at the directory and I get no errors:
./node_modules/.bin/eslint src/main/webapp/js/lcrf
I can see all of the linting errors that I need to fix.
I have also added the command into my package.json:
"scripts": {
"lint": "eslint src/main/webapp/js/lcrf"
},
Now I try to run the command with npm run lint. It lints my files and I get the same number of linting errors, but then node errors out. Here is my stacktrace:
npm ERR! Darwin 14.3.0
npm ERR! argv "node" "/usr/local/bin/npm" "run" "lint"
npm ERR! node v0.12.2
npm ERR! npm v2.7.4
npm ERR! code ELIFECYCLE
npm ERR! lcrf#0.0.0 lint: `eslint src/main/webapp/js/lcrf`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the lcrf#0.0.0 lint script 'eslint src/main/webapp/js/lcrf'.
npm ERR! This is most likely a problem with the lcrf package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! eslint src/main/webapp/js/lcrf
npm ERR! You can get their info via:
npm ERR! npm owner ls lcrf
npm ERR! There is likely additional logging output above.
What would cause this to happen? What is the difference in the 2 ways that I am running the command?
npm is freaking out over the non-zero return code from eslint. If you want lint errors to be an indication of "whoa, that's not supposed to happen, red alert, something is really wrong if this got published" then that's what you've got.
If you don't use the exit code (say, to stop subsequent build steps) and you just want the output to be just the eslint output and no subsequent npm freak out, use this in your package.json:
"lint": "eslint src/main/webapp/js/lcrf || exit 0"
Note this in "Best Practices" section of the npm scripts docs:
Don't exit with a non-zero error code unless you really mean it. Except for uninstall scripts, this will cause the npm action to fail, and potentially be rolled back. If the failure is minor or only will prevent some optional features, then it's better to just print a warning and exit successfully.