I am trying to do a https post in firebase function, and I tried to deploy the code below but it had problems with "request". I would like to know how to solve the issue below and do a https post.
Deployment error.
Function failed on loading user code. Error message: Code in file index.js can't be loaded.
Did you list all required modules in the package.json dependencies?
Detailed stack trace: Error: Cannot find module 'request'
at Function.Module._resolveFilename (module.js:548:15)
at Function.Module._load (module.js:475:25)
at Module.require (module.js:597:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (/srv/index.js:36:15)
at Module._compile (module.js:653:30)
at Object.Module._extensions..js (module.js:664:10)
at Module.load (module.js:566:32)
at tryModuleLoad (module.js:506:12)
at Function.Module._load (module.js:498:3)
I have executed this on command line, but I dont see any request module in package.json
npm install --save request
The following is my firebase function code
https://gist.github.com/axilaris/378a4a3b344b22ed09d6ed6b1ec4b14f
If you don't see the request module in your package.json, that means you probably ran the npm command in the wrong folder. You should run it from your "functions" folder, where package.json lives.
Related
I had node installed on "C:", then I moved the folders onto another drive.
When I try to execute a .js file, I get the following error, I don t know where can I modify to be able to run the code on that drive.
It worked fine on "C:" drive. Sorry, I`m new to this.
Thank you.
SyntaxError: Error parsing Z:\Resource Database\Dashboards data\node_modules\newman\package.json: Unexpected token in JSON at position 2687
at parse (<anonymous>)
at readPackage (node:internal/modules/cjs/loader:304:20)
at resolveExports (node:internal/modules/cjs/loader:479:15)
at Function.Module._findPath (node:internal/modules/cjs/loader:522:31)
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:919:27)
at Function.Module._load (node:internal/modules/cjs/loader:778:27)
at Module.require (node:internal/modules/cjs/loader:1005:19)
at require (node:internal/modules/cjs/helpers:102:18)
at Object.<anonymous> (Z:\Resource Database\Dashboards data\Automation-meter_readings\writeToFile.js:1:16)
at Module._compile (node:internal/modules/cjs/loader:1105:14) {
path: 'Z:\\Resource Database\\Dashboards data\\node_modules\\newman\\package.json'
}```
I'm trying to perform audit using Lighthouse CLI. My site requires authentication. How can I get Lighthouse CLI to analyse my site? Can I supply login credentials?
Also the CLI seems to be broken and/or not comply to documentation.
$ npm install -g lighthouse
$ lighthouse --help
C:\Users\kermit\AppData\Roaming\nvm\v8.11.1\node_modules\lighthouse\lighthouse-core\lib\url-shim.js:36
class URLShim extends URL {
^
ReferenceError: URL is not defined
at Object.<anonymous> (C:\Users\kermit\AppData\Roaming\nvm\v8.11.1\node_modules\lighthouse\lighthouse-core\lib\url-shim.js:36:23)
at Module._compile (module.js:652:30)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
at Module.require (module.js:596:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (C:\Users\kazuy\AppData\Roaming\nvm\v8.11.1\node_modules\lighthouse\lighthouse-core\lib\network-request.js:14:13)
at Module._compile (module.js:652:30)
Make sure you're using Node >= 10. URL got added at Node v10 (https://nodejs.org/api/globals.html#globals_url)
Please Upgrade Node and apply single or double quote on URL like below with L-CLI
lighthouse 'https://google.com' --port=9222
For the authenticated page, you have two below options
1. use --extra-headers={cookies}
2. use --port=9222 //port is debug port
I follow through installation tutorial by Apollo. And I totally confident that I did everything as is described in installation tutorial. However, when during the build of the project I received the compiler errors like:
TypeError: Cannot read property 'length' of undefined
at Object.yargs.command.command.command.argv [as handler] (/usr/local/lib/node_modules/apollo-codegen/src/cli.js:186:17)
at Object.runCommand (/usr/local/lib/node_modules/apollo- codegen/node_modules/yargs/lib/command.js:235:44)
at Object.parseArgs [as _parseArgs] (/usr/local/lib/node_modules/apollo-codegen/node_modules/yargs/yargs.js:1013:30)
at Object.get [as argv] (/usr/local/lib/node_modules/apollo-codegen/node_modules/yargs/yargs.js:957:21)
at Object.<anonymous> (/usr/local/lib/node_modules/apollo-codegen/lib/cli.js:197:5)
at Module._compile (module.js:660:30)
at Object.Module._extensions..js (module.js:671:10)
at Module.load (module.js:573:32)
at tryModuleLoad (module.js:513:12)
at Function.Module._load (module.js:505:3)
Command /bin/sh failed with exit code 1
and
++ exec apollo-codegen generate --schema schema.json --output API.swift
TypeError: Cannot read property 'length' of undefined
at Object.yargs.command.command.command.argv [as handler] (/usr/local/lib/node_modules/apollo-codegen/src/cli.js:186:17)
at Object.runCommand (/usr/local/lib/node_modules/apollo-codegen/node_modules/yargs/lib/command.js:235:44)
at Object.parseArgs [as _parseArgs] (/usr/local/lib/node_modules/apollo-codegen/node_modules/yargs/yargs.js:1013:30)
at Object.get [as argv] (/usr/local/lib/node_modules/apollo-codegen/node_modules/yargs/yargs.js:957:21)
at Object.<anonymous> (/usr/local/lib/node_modules/apollo-codegen/lib/cli.js:197:5)
at Module._compile (module.js:652:30)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
Command PhaseScriptExecution failed with a nonzero exit code
Why I receive this errors?
After spending a lot of time and did searches I understood why errors appeared. Tanks to #NiltiakSivad for her answer on GitHub issue discussion
Apollo script trying to find a file with the extension .graphql in a project folder with appropriates queries or mutations. If they do not exist, probably you will error as above. I think that Apollo team should warn their audience about such possible case in installation tutorial!
So, in order to successfully run the project make sure:
You're Apollo version compatible with apollo-codegen
You correctly add Apollo script
You have schema.json in the project folder
You have file with the extension .graphql in a project folder that
contains appropriates your schema.json query or mutation
I'm trying to setup a parse on google cloud but can't setup the cloud/main.js file
add cloud link on server.js
cloud: "/opt/bitnami/apps/parse/htdocs/cloud/main.js",
I got the following error:
SyntaxError: Unexpected token )
at createScript (vm.js:80:10)
at Object.runInThisContext (vm.js:139:10)
at Module._compile (module.js:616:28)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
at Module.require (module.js:596:17)
at require (internal/module.js:11:18)
at new ParseServer (/opt/bitnami/apps/parse/htdocs/node_modules/parse-server/lib/ParseServer.js:159:9)
error: Forever detected script exited with code: 1
When editing the ‘server.js’ file in ‘/opt/bitnami/apps/parse/htdocs/’ folder, make sure the ‘cloud’ folder exists and try setting the ‘cloud’ field string to “./cloud/main.js” to point to main.js file in cloud folder, the error could be related to incorrect path. If you are looking to add custom code to the Parse server, please follow the steps provided here [1].
[1] https://docs.bitnami.com/google/apps/parse/#how-to-add-your-custom-cloud-code-to-your-parse-server-stack
First of all, I created a tag and build my app with electron-packager:
node_modules/.bin/electron-packager . MyApp --platform=win32 --arch=x64 --icon='/home/user/Desktop/logo.ico' --asar=true --prune --overwrite
It worked fine! The problem is that now, for this release, I create a new tag, but I try to build my app with electron builder instead. I get the following error:
A JavaScript error occurred in the main process Uncaught Exception:
Error: Unable to find a valid app at Object.<anonymous> (E:\Project\dist\win-unpacke
d\resources\electron.asar\browser\init.js:128:9) at Module._compile (module.js:541:3
2) at Object.Module._extensions..js (module.js:550:10) at Module.load (module.js:458
:32) at tryModuleLoad(module.js:417:12) at Function.Module._load (module.js:409:3) a
t Function.Module.runMain (module.js:575:10) at run (bootstrap_node.js:360:7) at sta
rtup (bootstrap_node.js:152:9) at bootstrap_node.js:497:3
Furthermore, I try to build my app again with electron packager, but it didn't work now! I get the same problem.
I checkout my app to the previoulsy working tag, and it neither work.
Unfortunately, the code can not be distributed
Thanks!
The problem was in my package.json.
I miss to add "package.json" file to my files field