Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Functions tutorial, Index.js missing #1026

Closed
asasababoon opened this issue Nov 19, 2018 · 6 comments
Closed

Functions tutorial, Index.js missing #1026

asasababoon opened this issue Nov 19, 2018 · 6 comments
Assignees

Comments

@asasababoon
Copy link

asasababoon commented Nov 19, 2018

First off this issue seems to be discussed in Issue #631
#631
That tickets is closed, but does not seem to provide any details on how to fix the issue.

Version info

6.1.0

Platform Information

Windows 7, 64Bit, SP1

Steps to reproduce

Expected behavior

I expect firebase to deploy functions. What I assume is happening is that either index.js is not being created, or index.js is not saved to the correct path

Actual behavior

G:\FireBaseCloudFunctions>firebase deploy --debug
[2018-11-19T20:58:56.687Z] -----------------------------------------------------
-----------------
[2018-11-19T20:58:56.691Z] Command:       G:\Programs\NodeJS\node.exe C:\Users\.
Glenn\AppData\Roaming\npm\node_modules\firebase-tools\lib\bin\firebase.js deploy
 --debug
[2018-11-19T20:58:56.692Z] CLI Version:   6.1.0
[2018-11-19T20:58:56.692Z] Platform:      win32
[2018-11-19T20:58:56.692Z] Node Version:  v10.13.0
[2018-11-19T20:58:56.693Z] Time:          Mon Nov 19 2018 21:58:56 GMT+0100 (GMT
+01:00)
[2018-11-19T20:58:56.693Z] -----------------------------------------------------
-----------------

[2018-11-19T20:58:56.704Z] > command requires scopes: ["email","openid","https:/
/www.googleapis.com/auth/cloudplatformprojects.readonly","https://www.googleapis
.com/auth/firebase","https://www.googleapis.com/auth/cloud-platform"]
[2018-11-19T20:58:56.704Z] > authorizing via signed-in user
[2018-11-19T20:58:56.704Z] [iam] checking project functionstest-21343 for permis
sions ["cloudfunctions.functions.create","cloudfunctions.functions.delete","clou
dfunctions.functions.get","cloudfunctions.functions.list","cloudfunctions.functi
ons.update","cloudfunctions.operations.get","firebase.projects.get"]
[2018-11-19T20:58:56.707Z] >>> HTTP REQUEST POST https://cloudresourcemanager.go
ogleapis.com/v1/projects/functionstest-21343:testIamPermissions
 permissions=[cloudfunctions.functions.create, cloudfunctions.functions.delete,
cloudfunctions.functions.get, cloudfunctions.functions.list, cloudfunctions.func
tions.update, cloudfunctions.operations.get, firebase.projects.get]
[2018-11-19T20:58:57.463Z] <<< HTTP RESPONSE 200 content-type=application/json;
charset=UTF-8, vary=X-Origin, Referer, Origin,Accept-Encoding, date=Mon, 19 Nov
2018 20:58:57 GMT, server=ESF, cache-control=private, x-xss-protection=1; mode=b
lock, x-frame-options=SAMEORIGIN, x-content-type-options=nosniff, alt-svc=quic="
:443"; ma=2592000; v="44,43,39,35", accept-ranges=none, connection=close

=== Deploying to 'functionstest-21343'...

i  deploying functions
Running command: npm --prefix %RESOURCE_DIR% run lint

> functions@ lint G:\FireBaseCloudFunctions\functions
> tslint --project tsconfig.json

+  functions: Finished running predeploy script.
[2018-11-19T20:59:01.461Z] > [functions] package.json contents: {
  "name": "functions",
  "scripts": {
    "lint": "tslint --project tsconfig.json",
    "build": "tsc",
    "serve": "npm run build && firebase serve --only functions",
    "shell": "npm run build && firebase functions:shell",
    "start": "npm run shell",
    "deploy": "firebase deploy --only functions",
    "logs": "firebase functions:log"
  },
  "main": "lib/index.js",
  "dependencies": {
    "firebase-admin": "~6.0.0",
    "firebase-functions": "^2.1.0"
  },
  "devDependencies": {
    "tslint": "~5.8.0",
    "typescript": "~2.8.3"
  },
  "private": true
}

Error: functions\lib\index.js does not exist, can't deploy Firebase Functions

Having trouble? Try firebase deploy --help
@asasababoon asasababoon changed the title Functions tutorial, Index Functions tutorial, Index.js missing Nov 19, 2018
@bkendall
Copy link
Contributor

Can you tell us if the file functions/lib/index.js does exist or not? It looks like tslint is being run, but not npm run build?

@asasababoon
Copy link
Author

There is no Lib folder. just src and node_modules
image

@bkendall
Copy link
Contributor

Can you actually provide the contents of firebase.json? While I agree that the RESOURCE_DIRECTORY escaping/utilization might have to change, the predeploy array does need to have npm... run lint and npm... run build for it to work

@asasababoon
Copy link
Author

asasababoon commented Nov 19, 2018

Looking online, I have tried several adjustments, so far none have worked.

Based on:
#822 (comment)

I have settled for the folowing, as it seems to get me the furthers

`{
"functions":
{
//"predeploy": [
// "npm --prefix "$RESOURCE_DIR" run lint",
// "npm --prefix "$RESOURCE_DIR" run build"
//]

//	"predeploy": [
//"npm --prefix $Env:RESOURCE_DIR run lint"
//]

// after: (for Cmd.exe)
"predeploy": 
[
	"npm --prefix %RESOURCE_DIR% run lint"
]

}
}`

@bkendall
Copy link
Contributor

I'm a little baffled by that formatting, but... if %RESOURCE_DIR% works for you, your firebase.json should look like this:

{
  "functions": {
    "predeploy": [
      "npm --prefix %RESOURCE_DIR% run lint",
      "npm --prefix %RESOURCE_DIR% run build"
    ]
  }
}

specifically the build command must be included, otherwise the typescript code does not get transpiled to javascript, which is required for the deployment to work.

@asasababoon
Copy link
Author

Thank you so much, seems like that was exactly what I needed, and nice of you to specify why it works.

Sorry for the formatting in my previous post, my bad.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants