firebase / firebase-tools

The Firebase Command Line Tools
MIT License
4.02k stars 936 forks source link

Function load error; Cannot find module .... #784

Closed johnelliott closed 1 year ago

johnelliott commented 6 years ago

Version info

firebase-tools 3.18.5 node 8.11.2

Platform Information

OS X / macOS

Steps to reproduce

I have one function called server modeled after the sample code here. It's an https function that takes an Express app.

I ran $ firebase deploy --only functions,hosting.

I get errors after/at the end of the deploy seemingly during function start where there are node_modules that are not found.

Expected behavior

Modules should be available in node_modules

Actual behavior

I can't tell by the wording of the docs on dependencies whether the cloud functions servers will install child dependencies in addition to ones listed. It could also be a webpack issue because I am allowing some scss and es6 modules in node_modules to import differently via webpack rules. I am targeting node version 6 in my webpack build for the server code. This is because I reference built css files by their content-dependent hash name for server rendering.

If I manually install the classnames package in this error, I get the same sort of error for another dependency. I think this is just the first one that triggers the error, but presumably there are many.

I would like to know from the maintainers what kind of issue this seems like. Is it me, or perhaps I'm doing something unsupported?

Output I get:

Here's the last bit: ...

Function load error: 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 'classnames'
    at Function.Module._resolveFilename (module.js:476:15)
    at Function.Module._load (module.js:424:25)
    at Module.require (module.js:504:17)
    at require (internal/module.js:20:19)
    at Object.classnames (/user_code/dist/server.js:4332:18)
    at __webpack_require__ (/user_code/dist/server.js:21:30)
    at Object../node_modules/@material/react-button/index.js (/user_code/dist/server.js:96:19)
    at __webpack_require__ (/user_code/dist/server.js:21:30)
    at Object../src/App.js (/user_code/dist/server.js:3922:20)
    at __webpack_require__ (/user_code/dist/server.js:21:30)

....

Entire dump:

[2018-05-28T23:17:27.322Z] ----------------------------------------------------------------------
[2018-05-28T23:17:27.325Z] Command:       /Users/firstname/.nvm/versions/node/v8.11.2/bin/node /Users/firstname/.nvm/versions/node/v8.11.2/bin/firebase deploy --debug --only functions:server,hosting
[2018-05-28T23:17:27.325Z] CLI Version:   3.18.5
[2018-05-28T23:17:27.325Z] Platform:      darwin
[2018-05-28T23:17:27.325Z] Node Version:  v8.11.2
[2018-05-28T23:17:27.325Z] Time:          Mon May 28 2018 19:17:27 GMT-0400 (EDT)
[2018-05-28T23:17:27.325Z] ----------------------------------------------------------------------

[2018-05-28T23:17:27.332Z] > 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-05-28T23:17:27.332Z] > authorizing via signed-in user
[2018-05-28T23:17:27.333Z] >>> HTTP REQUEST GET https://admin.firebase.com/v1/projects/gc-test-a78cd  

 Mon May 28 2018 19:17:27 GMT-0400 (EDT)
[2018-05-28T23:17:27.670Z] <<< HTTP RESPONSE 200 server=nginx, date=Mon, 28 May 2018 23:17:27 GMT, content-type=application/json; charset=utf-8, content-length=108, connection=close, x-content-type-options=nosniff, strict-transport-security=max-age=31536000; includeSubdomains, cache-control=no-cache, no-store
[2018-05-28T23:17:27.670Z] >>> HTTP REQUEST GET https://admin.firebase.com/v1/database/gc-test-a78cd/tokens  

 Mon May 28 2018 19:17:27 GMT-0400 (EDT)
[2018-05-28T23:17:28.003Z] <<< HTTP RESPONSE 200 server=nginx, date=Mon, 28 May 2018 23:17:28 GMT, content-type=application/json; charset=utf-8, content-length=262, connection=close, x-content-type-options=nosniff, strict-transport-security=max-age=31536000; includeSubdomains, cache-control=no-cache, no-store

=== Deploying to 'gc-test-a78cd'...

i  deploying functions, hosting
pathName .
this.projectDir /Users/firstname/code/gc
Running command: npm run build && cp package.json dist/package.json

> webpacktest@1.0.0 build /Users/firstname/code/gc
> webpack-cli

clean-webpack-plugin: /Users/firstname/code/gc/dist has been removed.
clean-webpack-plugin: /Users/firstname/code/gc/dist has been removed.
babel-preset-env: `DEBUG` option

Using targets:
{
  "safari": "11"
}

Modules transform: commonjs

Using plugins:

Using polyfills:
  web.timers {"safari":"11"}
  web.immediate {"safari":"11"}
  web.dom.iterable {"safari":"11"}
Hash: c685a484d41899e7e67b55f70dd13b07ab28ee7f
Version: webpack 4.8.1
Child
    Hash: c685a484d41899e7e67b
    Time: 3003ms
    Built at: 2018-05-28 19:17:34
                                   Asset      Size  Chunks             Chunk Names
    3bb23ae1486afe0dac4b9032e5af1c65.png  1.48 MiB          [emitted]  
                               client.js  6.36 MiB  client  [emitted]  client
    Entrypoint client = client.js
    [./node_modules/css-loader/index.js!./node_modules/sass-loader/lib/loader.js??ref--5-2!./src/main.scss] ./node_modules/css-loader!./node_modules/sass-loader/lib/loader.js??ref--5-2!./src/main.scss 28.1 KiB {client} [built]
    [./node_modules/webpack/buildin/harmony-module.js] (webpack)/buildin/harmony-module.js 597 bytes {client} [built]
    [./node_modules/webpack/buildin/module.js] (webpack)/buildin/module.js 519 bytes {client} [built]
    [./src/App.js] 3.4 KiB {client} [built]
    [./src/client.js] 1.09 KiB {client} [built]
    [./src/firebase-config.js] 436 bytes {client} [built]
    [./src/main.scss] 1.2 KiB {client} [built]
    [./src/signup.png] 82 bytes {client} [built]
    [./src/store.js] 1.61 KiB {client} [built]
        + 406 hidden modules
Child
    Hash: 55f70dd13b07ab28ee7f
    Time: 2986ms
    Built at: 2018-05-28 19:17:34
                                        Asset      Size  Chunks             Chunk Names
    main.89438c5e33e8a72fd9ac97d801b151b0.css  27.1 KiB          [emitted]  
         3bb23ae1486afe0dac4b9032e5af1c65.png  1.48 MiB          [emitted]  
                                    server.js   387 KiB  server  [emitted]  server
    Entrypoint server = server.js
    [./src/Homepage.js] 1.99 KiB {server} [built]
    [./src/firebase-config.js] 436 bytes {server} [built]
    [./src/server.js] 1.43 KiB {server} [built]
    [./src/store.js] 1.61 KiB {server} [built]
    [compression] external "compression" 42 bytes {server} [built]
    [debug] external "debug" 42 bytes {server} [built]
    [dotenv] external "dotenv" 42 bytes {server} [built]
    [express] external "express" 42 bytes {server} [built]
    [firebase] external "firebase" 42 bytes {server} [built]
    [morgan] external "morgan" 42 bytes {server} [built]
    [react] external "react" 42 bytes {server} [built]
    [react-dom/server] external "react-dom/server" 42 bytes {server} [built]
    [react-redux] external "react-redux" 42 bytes {server} [built]
    [react-redux-firebase] external "react-redux-firebase" 42 bytes {server} [built]
    [redux] external "redux" 42 bytes {server} [built]
        + 29 hidden modules
✔  functions: Finished running predeploy script.
pathName .
this.projectDir /Users/firstname/code/gc
[2018-05-28T23:17:34.999Z] > [functions] package.json contents: {
  "name": "webpacktest",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "build": "webpack-cli",
    "buildP": "NODE_ENV=production npm run build",
    "build:client": "webpack-cli --config webpack.client.config.js",
    "build:server": "webpack-cli --config webpack.server.config.js",
    "dev:devserver": "webpack-dev-server --config webpack.client.config.js",
    "dev:assets": "webpack-cli --watch --config webpack.server.config.js",
    "dev:server": "nodemon --delay 1 --watch dist/server.js --exec node dist/server.js",
    "start": "npm run buildP && node dist/server.js",
    "firebase:serve": "firebase serve --only functions",
    "firebase:shell": "firebase functions:shell",
    "firebase:start": "npm run shell",
    "firebase:deploy": "firebase deploy --only functions",
    "firebase:logs": "firebase functions:log",
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [],
  "author": "firstname lastname <email@gmail.com> (http://primitivemachine.com/)",
  "license": "MIT",
  "dependencies": {
    "@material/animation": "^0.34.0",
    "@material/base": "^0.35.0",
    "@material/button": "^0.35.0",
    "@material/react-button": "^0.1.0",
    "@material/react-material-icon": "^0.1.0",
    "@material/react-ripple": "^0.1.0",
    "@material/react-top-app-bar": "^0.1.0",
    "@material/ripple": "^0.35.0",
    "@material/theme": "^0.35.0",
    "@material/top-app-bar": "^0.35.2",
    "@material/typography": "^0.35.0",
    "babel-plugin-transform-class-properties": "^6.24.1",
    "babel-plugin-transform-object-rest-spread": "^6.26.0",
    "compression": "^1.7.2",
    "debug": "^3.1.0",
    "dotenv": "^5.0.1",
    "express": "^4.16.3",
    "firebase": "^4.13.1",
    "firebase-admin": "^5.12.0",
    "firebase-functions": "^1.0.3",
    "morgan": "^1.9.0",
    "react": "^16.3.2",
    "react-dom": "^16.3.2",
    "react-redux": "^5.0.7",
    "react-redux-firebase": "^2.1.0",
    "redux": "^4.0.0"
  },
  "devDependencies": {
    "babel-cli": "^6.26.0",
    "babel-core": "^6.26.3",
    "babel-loader": "^7.1.4",
    "babel-preset-env": "^1.6.1",
    "babel-preset-react": "^6.24.1",
    "clean-webpack-plugin": "^0.1.19",
    "css-loader": "^0.28.11",
    "extract-loader": "^2.0.1",
    "file-loader": "^1.1.11",
    "firebase-tools": "^3.18.4",
    "node-sass": "^4.9.0",
    "nodemon": "^1.17.3",
    "sass-loader": "^7.0.1",
    "standard": "^11.0.1",
    "style-loader": "^0.21.0",
    "webpack": "^4.8.1",
    "webpack-cli": "^2.0.15",
    "webpack-dev-server": "^3.1.4",
    "webpack-node-externals": "^1.7.2"
  }
}
i  functions: ensuring necessary APIs are enabled...
[2018-05-28T23:17:34.999Z] >>> HTTP REQUEST GET https://servicemanagement.googleapis.com/v1/services/cloudfunctions.googleapis.com/projectSettings/gc-test-a78cd?view=CONSUMER_VIEW  

 Mon May 28 2018 19:17:34 GMT-0400 (EDT)
[2018-05-28T23:17:35.000Z] >>> HTTP REQUEST GET https://servicemanagement.googleapis.com/v1/services/runtimeconfig.googleapis.com/projectSettings/gc-test-a78cd?view=CONSUMER_VIEW  

 Mon May 28 2018 19:17:35 GMT-0400 (EDT)
[2018-05-28T23:17:35.589Z] <<< HTTP RESPONSE 200 content-type=application/json; charset=UTF-8, vary=X-Origin, Referer, Origin,Accept-Encoding, date=Mon, 28 May 2018 23:17:35 GMT, server=ESF, cache-control=private, x-xss-protection=1; mode=block, x-frame-options=SAMEORIGIN, x-content-type-options=nosniff, alt-svc=quic=":443"; ma=2592000; v="43,42,41,39,35", accept-ranges=none, connection=close
[2018-05-28T23:17:35.609Z] <<< HTTP RESPONSE 200 content-type=application/json; charset=UTF-8, vary=X-Origin, Referer, Origin,Accept-Encoding, date=Mon, 28 May 2018 23:17:35 GMT, server=ESF, cache-control=private, x-xss-protection=1; mode=block, x-frame-options=SAMEORIGIN, x-content-type-options=nosniff, alt-svc=quic=":443"; ma=2592000; v="43,42,41,39,35", accept-ranges=none, connection=close
✔  functions: all necessary APIs are enabled
[2018-05-28T23:17:35.609Z] >>> HTTP REQUEST GET https://cloudresourcemanager.googleapis.com/v1/projects/gc-test-a78cd  

 Mon May 28 2018 19:17:35 GMT-0400 (EDT)
[2018-05-28T23:17:35.901Z] <<< HTTP RESPONSE 200 content-type=application/json; charset=UTF-8, vary=X-Origin, Referer, Origin,Accept-Encoding, date=Mon, 28 May 2018 23:17:35 GMT, server=ESF, cache-control=private, x-xss-protection=1; mode=block, x-frame-options=SAMEORIGIN, x-content-type-options=nosniff, alt-svc=quic=":443"; ma=2592000; v="43,42,41,39,35", accept-ranges=none, connection=close
[2018-05-28T23:17:35.901Z] >>> HTTP REQUEST GET https://mobilesdk-pa.googleapis.com/v1/projects/42592905751:getServerAppConfig  

 Mon May 28 2018 19:17:35 GMT-0400 (EDT)
[2018-05-28T23:17:36.210Z] <<< HTTP RESPONSE 200 content-type=application/json; charset=UTF-8, vary=X-Origin, Referer, Origin,Accept-Encoding, date=Mon, 28 May 2018 23:17:36 GMT, server=ESF, cache-control=private, x-xss-protection=1; mode=block, x-frame-options=SAMEORIGIN, x-content-type-options=nosniff, alt-svc=quic=":443"; ma=2592000; v="43,42,41,39,35", accept-ranges=none, connection=close
i  functions: preparing . directory for uploading...
pathName .
this.projectDir /Users/firstname/code/gc
[2018-05-28T23:17:36.212Z] >>> HTTP REQUEST GET https://runtimeconfig.googleapis.com/v1beta1/projects/gc-test-a78cd/configs  

 Mon May 28 2018 19:17:36 GMT-0400 (EDT)
[2018-05-28T23:17:36.389Z] <<< HTTP RESPONSE 200 content-type=application/json; charset=UTF-8, vary=X-Origin, Referer, Origin,Accept-Encoding, date=Mon, 28 May 2018 23:17:36 GMT, server=ESF, cache-control=private, x-xss-protection=1; mode=block, x-frame-options=SAMEORIGIN, x-content-type-options=nosniff, alt-svc=quic=":443"; ma=2592000; v="43,42,41,39,35", accept-ranges=none, connection=close
i  functions: packaged . (10.72 MB) for uploading
[2018-05-28T23:17:37.410Z] >>> HTTP REQUEST POST https://cloudfunctions.googleapis.com/v1/projects/gc-test-a78cd/locations/us-central1/functions:generateUploadUrl  

 Mon May 28 2018 19:17:37 GMT-0400 (EDT)
[2018-05-28T23:17:37.936Z] <<< HTTP RESPONSE 200 content-type=application/json; charset=UTF-8, vary=X-Origin, Referer, Origin,Accept-Encoding, date=Mon, 28 May 2018 23:17:37 GMT, server=ESF, cache-control=private, x-xss-protection=1; mode=block, x-frame-options=SAMEORIGIN, x-content-type-options=nosniff, alt-svc=quic=":443"; ma=2592000; v="43,42,41,39,35", accept-ranges=none, connection=close
[2018-05-28T23:17:37.936Z] >>> HTTP REQUEST PUT https://storage.googleapis.com/gcf-upload-us-central1-f8570209-4af1-436c-ad62-29e05ef5eaee/4afbbfdf-05cc-4c27-995c-7aa9a4fed25e.zip?GoogleAccessId=42592905751@cloudservices.gserviceaccount.com&Expires=1527551257&Signature=Gm1D4yI3b%2BKLI5bsHsOvA2UkxupHcfa48VUUMDJ%2FHRr2yfS8Zy5efhg7H4aX6hLxBjFxMy0t3Mg9lBML%2F7puQg4Hheg4fbfUEckeORirS33wDGOw20POfzFeiKOQ%2B%2FZEMyIP059MYLDFrySvStF98mhvNYYbij63qOysY%2FEnBi8Tkr6WagiKHRzx8%2Fu1a8wFlCg0KM7N9KNG4%2FfPpZXePPKE8a96j4Qq9Pt%2BemOGuThDLU6x4pRSiW4RNhbNqZn%2BZ%2BIUEMxD07BEMmhArVVomMe9UOi6P7WvQaf5EJvf7EmmdsY8U8D7CpBgzPLX2aBUfojtB1BWacHXZmZcp8heFw%3D%3D  
 ReadStream {
  _readableState: 
   ReadableState {
     objectMode: false,
     highWaterMark: 65536,
     buffer: BufferList { head: [Object], tail: [Object], length: 1 },
     length: 65536,
     pipes: null,
     pipesCount: 0,
     flowing: null,
     ended: false,
     endEmitted: false,
     reading: false,
     sync: false,
     needReadable: false,
     emittedReadable: true,
     readableListening: false,
     resumeScheduled: false,
     destroyed: false,
     defaultEncoding: 'utf8',
     awaitDrain: 0,
     readingMore: false,
     decoder: null,
     encoding: null },
  readable: true,
  domain: null,
  _events: { end: [Function] },
  _eventsCount: 1,
  _maxListeners: undefined,
  path: '/var/folders/h9/9gx2b4rs6d71j8l0lvdtq4wh0000gn/T/firebase-functions-95885NdU01jP3GK9f.zip',
  fd: 19,
  flags: 'r',
  mode: 438,
  start: undefined,
  end: Infinity,
  autoClose: true,
  pos: undefined,
  bytesRead: 65536 } 
 Mon May 28 2018 19:17:37 GMT-0400 (EDT)
[2018-05-28T23:17:40.763Z] <<< HTTP RESPONSE 200 x-guploader-uploadid=AEnB2UoxdHWpgH2KITTG_bKKTrLZrqEARrPWTGiNny3sCxXAw0HBBhDwSy050INAB94bz99_-bFsVKOxPdN2tfNMqftp8P_Kkw, etag="da890e773e00deb95c9b6d798722703a", x-goog-generation=1527549460765987, x-goog-metageneration=1, x-goog-hash=crc32c=b+lVPw==, md5=2okOdz4A3rlcm215hyJwOg==, x-goog-stored-content-length=11237168, x-goog-stored-content-encoding=identity, vary=Origin, content-length=0, date=Mon, 28 May 2018 23:17:40 GMT, server=UploadServer, content-type=text/html; charset=UTF-8, alt-svc=hq=":443"; ma=2592000; quic=51303433; quic=51303432; quic=51303431; quic=51303339; quic=51303335,quic=":443"; ma=2592000; v="43,42,41,39,35", connection=close
✔  functions: . folder uploaded successfully
i  hosting: preparing dist directory for upload...
pathName dist
this.projectDir /Users/firstname/code/gc
⚠  Warning: Public directory does not contain index.html
[2018-05-28T23:17:40.997Z] >>> HTTP REQUEST PUT https://deploy.firebase.com/v1/hosting/gc-test-a78cd/uploads/-LDd1ixTygEaDiiKrU9z?fileCount=5&message=  

 Mon May 28 2018 19:17:40 GMT-0400 (EDT)
Uploading: [                                        ] 0%[2018-05-28T23:17:43.159Z] <<< HTTP RESPONSE 200 server=nginx, date=Mon, 28 May 2018 23:17:43 GMT, content-type=application/json; charset=utf-8, content-length=49, connection=close, access-control-allow-origin=*, access-control-allow-methods=GET, PUT, POST, DELETE, OPTIONS, strict-transport-security=max-age=31556926; includeSubDomains; preload, x-content-type-options=nosniff
[2018-05-28T23:17:43.159Z] [hosting] .tgz uploaded successfully, waiting for extraction
✔  hosting: 5 files uploaded successfully
[2018-05-28T23:17:43.941Z] [hosting] deploy completed after 3178ms
[2018-05-28T23:17:44.058Z] >>> HTTP REQUEST GET https://cloudfunctions.googleapis.com/v1/projects/gc-test-a78cd/locations/us-central1/functions  

 Mon May 28 2018 19:17:44 GMT-0400 (EDT)
[2018-05-28T23:17:44.412Z] <<< HTTP RESPONSE 200 content-type=application/json; charset=UTF-8, vary=X-Origin, Referer, Origin,Accept-Encoding, date=Mon, 28 May 2018 23:17:44 GMT, server=ESF, cache-control=private, x-xss-protection=1; mode=block, x-frame-options=SAMEORIGIN, x-content-type-options=nosniff, alt-svc=quic=":443"; ma=2592000; v="43,42,41,39,35", accept-ranges=none, connection=close
[2018-05-28T23:17:44.412Z] > [functions] filtering triggers to: [
  "server"
]
i  functions: current functions in project: server
i  functions: uploading functions in project: server
i  functions: updating function server...
[2018-05-28T23:17:44.414Z] Trigger is:  {"httpsTrigger":{}}
[2018-05-28T23:17:44.415Z] >>> HTTP REQUEST PATCH https://cloudfunctions.googleapis.com/v1/projects/gc-test-a78cd/locations/us-central1/functions/server 
query params: {"updateMask":"sourceUploadUrl,name,labels,httpsTrigger"} 
 { sourceUploadUrl: 'https://storage.googleapis.com/gcf-upload-us-central1-f8570209-4af1-436c-ad62-29e05ef5eaee/4afbbfdf-05cc-4c27-995c-7aa9a4fed25e.zip?GoogleAccessId=42592905751@cloudservices.gserviceaccount.com&Expires=1527551257&Signature=Gm1D4yI3b%2BKLI5bsHsOvA2UkxupHcfa48VUUMDJ%2FHRr2yfS8Zy5efhg7H4aX6hLxBjFxMy0t3Mg9lBML%2F7puQg4Hheg4fbfUEckeORirS33wDGOw20POfzFeiKOQ%2B%2FZEMyIP059MYLDFrySvStF98mhvNYYbij63qOysY%2FEnBi8Tkr6WagiKHRzx8%2Fu1a8wFlCg0KM7N9KNG4%2FfPpZXePPKE8a96j4Qq9Pt%2BemOGuThDLU6x4pRSiW4RNhbNqZn%2BZ%2BIUEMxD07BEMmhArVVomMe9UOi6P7WvQaf5EJvf7EmmdsY8U8D7CpBgzPLX2aBUfojtB1BWacHXZmZcp8heFw%3D%3D',
  name: 'projects/gc-test-a78cd/locations/us-central1/functions/server',
  labels: { 'deployment-tool': 'cli-firebase' },
  httpsTrigger: {} } 
 Mon May 28 2018 19:17:44 GMT-0400 (EDT)
[2018-05-28T23:17:44.834Z] <<< HTTP RESPONSE 200 content-type=application/json; charset=UTF-8, vary=X-Origin, Referer, Origin,Accept-Encoding, date=Mon, 28 May 2018 23:17:44 GMT, server=ESF, cache-control=private, x-xss-protection=1; mode=block, x-frame-options=SAMEORIGIN, x-content-type-options=nosniff, alt-svc=quic=":443"; ma=2592000; v="43,42,41,39,35", accept-ranges=none, connection=close
[2018-05-28T23:17:44.836Z] >>> HTTP REQUEST GET https://cloudfunctions.googleapis.com/v1/projects/gc-test-a78cd/locations/us-central1/functions  

 Mon May 28 2018 19:17:44 GMT-0400 (EDT)
[2018-05-28T23:17:45.173Z] <<< HTTP RESPONSE 200 content-type=application/json; charset=UTF-8, vary=X-Origin, Referer, Origin,Accept-Encoding, date=Mon, 28 May 2018 23:17:45 GMT, server=ESF, cache-control=private, x-xss-protection=1; mode=block, x-frame-options=SAMEORIGIN, x-content-type-options=nosniff, alt-svc=quic=":443"; ma=2592000; v="43,42,41,39,35", accept-ranges=none, connection=close
[2018-05-28T23:17:45.174Z] >>> HTTP REQUEST GET https://cloudfunctions.googleapis.com/v1/operations/Z2MtdGVzdC1hNzhjZC91cy1jZW50cmFsMS9zZXJ2ZXIvWS1MV0xHdi0ta0E  

 Mon May 28 2018 19:17:45 GMT-0400 (EDT)
[2018-05-28T23:17:45.514Z] <<< HTTP RESPONSE 200 content-type=application/json; charset=UTF-8, vary=X-Origin, Referer, Origin,Accept-Encoding, date=Mon, 28 May 2018 23:17:45 GMT, server=ESF, cache-control=private, x-xss-protection=1; mode=block, x-frame-options=SAMEORIGIN, x-content-type-options=nosniff, alt-svc=quic=":443"; ma=2592000; v="43,42,41,39,35", accept-ranges=none, connection=close
[2018-05-28T23:17:47.516Z] >>> HTTP REQUEST GET https://cloudfunctions.googleapis.com/v1/operations/Z2MtdGVzdC1hNzhjZC91cy1jZW50cmFsMS9zZXJ2ZXIvWS1MV0xHdi0ta0E  

 Mon May 28 2018 19:17:47 GMT-0400 (EDT)
[2018-05-28T23:17:48.073Z] <<< HTTP RESPONSE 200 content-type=application/json; charset=UTF-8, vary=X-Origin, Referer, Origin,Accept-Encoding, date=Mon, 28 May 2018 23:17:47 GMT, server=ESF, cache-control=private, x-xss-protection=1; mode=block, x-frame-options=SAMEORIGIN, x-content-type-options=nosniff, alt-svc=quic=":443"; ma=2592000; v="43,42,41,39,35", accept-ranges=none, connection=close
[2018-05-28T23:17:50.076Z] >>> HTTP REQUEST GET https://cloudfunctions.googleapis.com/v1/operations/Z2MtdGVzdC1hNzhjZC91cy1jZW50cmFsMS9zZXJ2ZXIvWS1MV0xHdi0ta0E  

 Mon May 28 2018 19:17:50 GMT-0400 (EDT)
[2018-05-28T23:17:50.532Z] <<< HTTP RESPONSE 200 content-type=application/json; charset=UTF-8, vary=X-Origin, Referer, Origin,Accept-Encoding, date=Mon, 28 May 2018 23:17:50 GMT, server=ESF, cache-control=private, x-xss-protection=1; mode=block, x-frame-options=SAMEORIGIN, x-content-type-options=nosniff, alt-svc=quic=":443"; ma=2592000; v="43,42,41,39,35", accept-ranges=none, connection=close
[2018-05-28T23:17:52.535Z] >>> HTTP REQUEST GET https://cloudfunctions.googleapis.com/v1/operations/Z2MtdGVzdC1hNzhjZC91cy1jZW50cmFsMS9zZXJ2ZXIvWS1MV0xHdi0ta0E  

 Mon May 28 2018 19:17:52 GMT-0400 (EDT)
[2018-05-28T23:17:52.851Z] <<< HTTP RESPONSE 200 content-type=application/json; charset=UTF-8, vary=X-Origin, Referer, Origin,Accept-Encoding, date=Mon, 28 May 2018 23:17:52 GMT, server=ESF, cache-control=private, x-xss-protection=1; mode=block, x-frame-options=SAMEORIGIN, x-content-type-options=nosniff, alt-svc=quic=":443"; ma=2592000; v="43,42,41,39,35", accept-ranges=none, connection=close
[2018-05-28T23:17:54.855Z] >>> HTTP REQUEST GET https://cloudfunctions.googleapis.com/v1/operations/Z2MtdGVzdC1hNzhjZC91cy1jZW50cmFsMS9zZXJ2ZXIvWS1MV0xHdi0ta0E  

 Mon May 28 2018 19:17:54 GMT-0400 (EDT)
[2018-05-28T23:17:55.446Z] <<< HTTP RESPONSE 200 content-type=application/json; charset=UTF-8, vary=X-Origin, Referer, Origin,Accept-Encoding, date=Mon, 28 May 2018 23:17:55 GMT, server=ESF, cache-control=private, x-xss-protection=1; mode=block, x-frame-options=SAMEORIGIN, x-content-type-options=nosniff, alt-svc=quic=":443"; ma=2592000; v="43,42,41,39,35", accept-ranges=none, connection=close
[2018-05-28T23:17:57.450Z] >>> HTTP REQUEST GET https://cloudfunctions.googleapis.com/v1/operations/Z2MtdGVzdC1hNzhjZC91cy1jZW50cmFsMS9zZXJ2ZXIvWS1MV0xHdi0ta0E  

 Mon May 28 2018 19:17:57 GMT-0400 (EDT)
[2018-05-28T23:17:57.783Z] <<< HTTP RESPONSE 200 content-type=application/json; charset=UTF-8, vary=X-Origin, Referer, Origin,Accept-Encoding, date=Mon, 28 May 2018 23:17:57 GMT, server=ESF, cache-control=private, x-xss-protection=1; mode=block, x-frame-options=SAMEORIGIN, x-content-type-options=nosniff, alt-svc=quic=":443"; ma=2592000; v="43,42,41,39,35", accept-ranges=none, connection=close
[2018-05-28T23:17:59.788Z] >>> HTTP REQUEST GET https://cloudfunctions.googleapis.com/v1/operations/Z2MtdGVzdC1hNzhjZC91cy1jZW50cmFsMS9zZXJ2ZXIvWS1MV0xHdi0ta0E  

 Mon May 28 2018 19:17:59 GMT-0400 (EDT)
[2018-05-28T23:18:00.362Z] <<< HTTP RESPONSE 200 content-type=application/json; charset=UTF-8, vary=X-Origin, Referer, Origin,Accept-Encoding, date=Mon, 28 May 2018 23:18:00 GMT, server=ESF, cache-control=private, x-xss-protection=1; mode=block, x-frame-options=SAMEORIGIN, x-content-type-options=nosniff, alt-svc=quic=":443"; ma=2592000; v="43,42,41,39,35", accept-ranges=none, connection=close
[2018-05-28T23:18:02.367Z] >>> HTTP REQUEST GET https://cloudfunctions.googleapis.com/v1/operations/Z2MtdGVzdC1hNzhjZC91cy1jZW50cmFsMS9zZXJ2ZXIvWS1MV0xHdi0ta0E  

 Mon May 28 2018 19:18:02 GMT-0400 (EDT)
[2018-05-28T23:18:02.819Z] <<< HTTP RESPONSE 200 content-type=application/json; charset=UTF-8, vary=X-Origin, Referer, Origin,Accept-Encoding, date=Mon, 28 May 2018 23:18:02 GMT, server=ESF, cache-control=private, x-xss-protection=1; mode=block, x-frame-options=SAMEORIGIN, x-content-type-options=nosniff, alt-svc=quic=":443"; ma=2592000; v="43,42,41,39,35", accept-ranges=none, connection=close
[2018-05-28T23:18:04.820Z] >>> HTTP REQUEST GET https://cloudfunctions.googleapis.com/v1/operations/Z2MtdGVzdC1hNzhjZC91cy1jZW50cmFsMS9zZXJ2ZXIvWS1MV0xHdi0ta0E  

 Mon May 28 2018 19:18:04 GMT-0400 (EDT)
[2018-05-28T23:18:05.277Z] <<< HTTP RESPONSE 200 content-type=application/json; charset=UTF-8, vary=X-Origin, Referer, Origin,Accept-Encoding, date=Mon, 28 May 2018 23:18:05 GMT, server=ESF, cache-control=private, x-xss-protection=1; mode=block, x-frame-options=SAMEORIGIN, x-content-type-options=nosniff, alt-svc=quic=":443"; ma=2592000; v="43,42,41,39,35", accept-ranges=none, connection=close
[2018-05-28T23:18:07.282Z] >>> HTTP REQUEST GET https://cloudfunctions.googleapis.com/v1/operations/Z2MtdGVzdC1hNzhjZC91cy1jZW50cmFsMS9zZXJ2ZXIvWS1MV0xHdi0ta0E  

 Mon May 28 2018 19:18:07 GMT-0400 (EDT)
[2018-05-28T23:18:07.735Z] <<< HTTP RESPONSE 200 content-type=application/json; charset=UTF-8, vary=X-Origin, Referer, Origin,Accept-Encoding, date=Mon, 28 May 2018 23:18:07 GMT, server=ESF, cache-control=private, x-xss-protection=1; mode=block, x-frame-options=SAMEORIGIN, x-content-type-options=nosniff, alt-svc=quic=":443"; ma=2592000; v="43,42,41,39,35", accept-ranges=none, connection=close
[2018-05-28T23:18:09.738Z] >>> HTTP REQUEST GET https://cloudfunctions.googleapis.com/v1/operations/Z2MtdGVzdC1hNzhjZC91cy1jZW50cmFsMS9zZXJ2ZXIvWS1MV0xHdi0ta0E  

 Mon May 28 2018 19:18:09 GMT-0400 (EDT)
[2018-05-28T23:18:10.192Z] <<< HTTP RESPONSE 200 content-type=application/json; charset=UTF-8, vary=X-Origin, Referer, Origin,Accept-Encoding, date=Mon, 28 May 2018 23:18:10 GMT, server=ESF, cache-control=private, x-xss-protection=1; mode=block, x-frame-options=SAMEORIGIN, x-content-type-options=nosniff, alt-svc=quic=":443"; ma=2592000; v="43,42,41,39,35", accept-ranges=none, connection=close
[2018-05-28T23:18:12.194Z] >>> HTTP REQUEST GET https://cloudfunctions.googleapis.com/v1/operations/Z2MtdGVzdC1hNzhjZC91cy1jZW50cmFsMS9zZXJ2ZXIvWS1MV0xHdi0ta0E  

 Mon May 28 2018 19:18:12 GMT-0400 (EDT)
[2018-05-28T23:18:12.650Z] <<< HTTP RESPONSE 200 content-type=application/json; charset=UTF-8, vary=X-Origin, Referer, Origin,Accept-Encoding, date=Mon, 28 May 2018 23:18:12 GMT, server=ESF, cache-control=private, x-xss-protection=1; mode=block, x-frame-options=SAMEORIGIN, x-content-type-options=nosniff, alt-svc=quic=":443"; ma=2592000; v="43,42,41,39,35", accept-ranges=none, connection=close
[2018-05-28T23:18:14.655Z] >>> HTTP REQUEST GET https://cloudfunctions.googleapis.com/v1/operations/Z2MtdGVzdC1hNzhjZC91cy1jZW50cmFsMS9zZXJ2ZXIvWS1MV0xHdi0ta0E  

 Mon May 28 2018 19:18:14 GMT-0400 (EDT)
[2018-05-28T23:18:14.986Z] <<< HTTP RESPONSE 200 content-type=application/json; charset=UTF-8, vary=X-Origin, Referer, Origin,Accept-Encoding, date=Mon, 28 May 2018 23:18:14 GMT, server=ESF, cache-control=private, x-xss-protection=1; mode=block, x-frame-options=SAMEORIGIN, x-content-type-options=nosniff, alt-svc=quic=":443"; ma=2592000; v="43,42,41,39,35", accept-ranges=none, connection=close
[2018-05-28T23:18:16.992Z] >>> HTTP REQUEST GET https://cloudfunctions.googleapis.com/v1/operations/Z2MtdGVzdC1hNzhjZC91cy1jZW50cmFsMS9zZXJ2ZXIvWS1MV0xHdi0ta0E  

 Mon May 28 2018 19:18:16 GMT-0400 (EDT)
[2018-05-28T23:18:17.565Z] <<< HTTP RESPONSE 200 content-type=application/json; charset=UTF-8, vary=X-Origin, Referer, Origin,Accept-Encoding, date=Mon, 28 May 2018 23:18:17 GMT, server=ESF, cache-control=private, x-xss-protection=1; mode=block, x-frame-options=SAMEORIGIN, x-content-type-options=nosniff, alt-svc=quic=":443"; ma=2592000; v="43,42,41,39,35", accept-ranges=none, connection=close
[2018-05-28T23:18:19.569Z] >>> HTTP REQUEST GET https://cloudfunctions.googleapis.com/v1/operations/Z2MtdGVzdC1hNzhjZC91cy1jZW50cmFsMS9zZXJ2ZXIvWS1MV0xHdi0ta0E  

 Mon May 28 2018 19:18:19 GMT-0400 (EDT)
[2018-05-28T23:18:19.714Z] <<< HTTP RESPONSE 200 content-type=application/json; charset=UTF-8, vary=X-Origin, Referer, Origin,Accept-Encoding, date=Mon, 28 May 2018 23:18:19 GMT, server=ESF, cache-control=private, x-xss-protection=1; mode=block, x-frame-options=SAMEORIGIN, x-content-type-options=nosniff, alt-svc=quic=":443"; ma=2592000; v="43,42,41,39,35", accept-ranges=none, connection=close
[2018-05-28T23:18:21.719Z] >>> HTTP REQUEST GET https://cloudfunctions.googleapis.com/v1/operations/Z2MtdGVzdC1hNzhjZC91cy1jZW50cmFsMS9zZXJ2ZXIvWS1MV0xHdi0ta0E  

 Mon May 28 2018 19:18:21 GMT-0400 (EDT)
[2018-05-28T23:18:22.175Z] <<< HTTP RESPONSE 200 content-type=application/json; charset=UTF-8, vary=X-Origin, Referer, Origin,Accept-Encoding, date=Mon, 28 May 2018 23:18:22 GMT, server=ESF, cache-control=private, x-xss-protection=1; mode=block, x-frame-options=SAMEORIGIN, x-content-type-options=nosniff, alt-svc=quic=":443"; ma=2592000; v="43,42,41,39,35", accept-ranges=none, connection=close
[2018-05-28T23:18:24.180Z] >>> HTTP REQUEST GET https://cloudfunctions.googleapis.com/v1/operations/Z2MtdGVzdC1hNzhjZC91cy1jZW50cmFsMS9zZXJ2ZXIvWS1MV0xHdi0ta0E  

 Mon May 28 2018 19:18:24 GMT-0400 (EDT)
[2018-05-28T23:18:24.631Z] <<< HTTP RESPONSE 200 content-type=application/json; charset=UTF-8, vary=X-Origin, Referer, Origin,Accept-Encoding, date=Mon, 28 May 2018 23:18:24 GMT, server=ESF, cache-control=private, x-xss-protection=1; mode=block, x-frame-options=SAMEORIGIN, x-content-type-options=nosniff, alt-svc=quic=":443"; ma=2592000; v="43,42,41,39,35", accept-ranges=none, connection=close
[2018-05-28T23:18:26.633Z] >>> HTTP REQUEST GET https://cloudfunctions.googleapis.com/v1/operations/Z2MtdGVzdC1hNzhjZC91cy1jZW50cmFsMS9zZXJ2ZXIvWS1MV0xHdi0ta0E  

 Mon May 28 2018 19:18:26 GMT-0400 (EDT)
[2018-05-28T23:18:27.089Z] <<< HTTP RESPONSE 200 content-type=application/json; charset=UTF-8, vary=X-Origin, Referer, Origin,Accept-Encoding, date=Mon, 28 May 2018 23:18:26 GMT, server=ESF, cache-control=private, x-xss-protection=1; mode=block, x-frame-options=SAMEORIGIN, x-content-type-options=nosniff, alt-svc=quic=":443"; ma=2592000; v="43,42,41,39,35", accept-ranges=none, connection=close
⚠  functions[server]: Deployment error.
Function load error: 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 'classnames'
    at Function.Module._resolveFilename (module.js:476:15)
    at Function.Module._load (module.js:424:25)
    at Module.require (module.js:504:17)
    at require (internal/module.js:20:19)
    at Object.classnames (/user_code/dist/server.js:4332:18)
    at __webpack_require__ (/user_code/dist/server.js:21:30)
    at Object../node_modules/@material/react-button/index.js (/user_code/dist/server.js:96:19)
    at __webpack_require__ (/user_code/dist/server.js:21:30)
    at Object../src/App.js (/user_code/dist/server.js:3922:20)
    at __webpack_require__ (/user_code/dist/server.js:21:30)

Functions deploy had errors. To continue deploying other features (such as database), run:
    firebase deploy --except functions

Error: Functions did not deploy properly.
laurenzlong commented 6 years ago

Hi, what does your package.json look like? Yes, the runtime will install all child dependencies as well. But one thing to keep in mind is that the entire node_modules folder is ignored during uploading of source code, so your package.json has to contain all of your dependencies and cannot reference any files inside of 'node_modules'. In other words, your functions should still be able to work if you ran the following commands inside of the functions folder:

rm -rf node_modules
npm install
johnelliott commented 6 years ago

Hello, it looks like the whole package is there in the debug output near the top.

Once the files are built, I think the command you showed here should work. I don’t think I have any private modules or ones unavailable outside npm. I will confirm this once I get back to my computer.

I took a look at my bundle to see if there were any obviously broken require calls, so I’ll have to do a more complete look and update this with more information.

johnelliott commented 6 years ago

OK, here is my package.json and webpack config for the server code.

I'm still working on finding the source of the problem. It would be easier if I could look at what firebase has installed so I can see what is working and not working, and what version of npm it's running so I can better imitate it locally or something.

package.json:

{
  "name": "webpacktest",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "build": "webpack-cli",
    "buildP": "NODE_ENV=production npm run build",
    "build:client": "webpack-cli --config webpack.client.config.js",
    "build:server": "webpack-cli --config webpack.server.config.js",
    "dev:devserver": "webpack-dev-server --config webpack.client.config.js",
    "dev:assets": "webpack-cli --watch --config webpack.server.config.js",
    "dev:server": "nodemon --delay 1 --watch dist/server.js --exec node dist/server.js",
    "start": "npm run buildP && node dist/server.js",
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [],
  "author": "John Elliott <johnelliott703@gmail.com> (http://primitivemachine.com/)",
  "license": "MIT",
  "dependencies": {
    "@material/animation": "^0.34.0",
    "@material/base": "^0.35.0",
    "@material/button": "^0.35.0",
    "@material/react-button": "^0.1.0",
    "@material/react-material-icon": "^0.1.0",
    "@material/react-ripple": "^0.1.0",
    "@material/react-top-app-bar": "^0.1.0",
    "@material/ripple": "^0.35.0",
    "@material/theme": "^0.35.0",
    "@material/top-app-bar": "^0.35.2",
    "@material/typography": "^0.35.0",
    "babel-plugin-transform-class-properties": "^6.24.1",
    "babel-plugin-transform-object-rest-spread": "^6.26.0",
    "compression": "^1.7.2",
    "debug": "^3.1.0",
    "dotenv": "^5.0.1",
    "express": "^4.16.3",
    "firebase": "^4.13.1",
    "firebase-admin": "^5.12.0",
    "firebase-functions": "^1.0.3",
    "morgan": "^1.9.0",
    "react": "^16.3.2",
    "react-dom": "^16.3.2",
    "react-redux": "^5.0.7",
    "react-redux-firebase": "^2.1.0",
    "redux": "^4.0.0"
  },
  "devDependencies": {
    "babel-cli": "^6.26.0",
    "babel-core": "^6.26.3",
    "babel-loader": "^7.1.4",
    "babel-preset-env": "^1.6.1",
    "babel-preset-react": "^6.24.1",
    "clean-webpack-plugin": "^0.1.19",
    "css-loader": "^0.28.11",
    "extract-loader": "^2.0.1",
    "file-loader": "^1.1.11",
    "firebase-tools": "^3.18.4",
    "node-sass": "^4.9.0",
    "nodemon": "^1.17.3",
    "sass-loader": "^7.0.1",
    "standard": "^11.0.1",
    "style-loader": "^0.21.0",
    "webpack": "^4.8.1",
    "webpack-cli": "^2.0.15",
    "webpack-dev-server": "^3.1.4",
    "webpack-node-externals": "^1.7.2"
  }
}

Here's my webpack configuration

const serverConfig = {
  target: 'node',
  externals: [nodeExternals({ whitelist: [/^@material/] })],
  mode,
  devtool,
  entry: { server: path.join(__dirname, 'src/server.js') },
  optimization: globalOptimization, // just minify etc.
  module: {
    rules: [
      ...globalRules, // just file-loader for static assets
      {
        test: /\.scss$/,
        use: [
          {
            loader: 'file-loader',
            options: {
              emit: true,
              name: '[name].[hash].css'
            }
          },
          'extract-loader',
          'css-loader',
          sassLoader
        ]
      },
      {
        test: /\.js$/,
        include: path.join(__dirname, 'node_modules', '@material'), // allow es6 imports from these packages into webpack...
        loader: 'babel-loader',
        options: {
          presets: [
            ['env', {
              debug: true,
              targets: { node: 6 } //  GCP seems to support this
            }],
            'react'
          ],
          plugins: [
            'transform-class-properties',
            'transform-object-rest-spread'
          ]
        }
      },
      {
        test: /\.js$/,
        exclude: /node_modules/,
        loader: 'babel-loader',
        options: {
          presets: [
            ['env', {
              debug: true,
              targets: { node: 6 }
            }],
            'react'
          ]
        }
      }
    ]
  },
  plugins: [
    // banner, hot module, named modules, but only for development
    ...globalPlugins,
    ...serverPlugins
  ],
  output
}
laurenzlong commented 6 years ago

@johnelliott The Google Cloud Functions runtime uses Node 6, not sure what version of npm. It will only run "npm install", it will not run any build commands. So when you're testing it locally, make sure it works with

rm -rf node_modules
npm install
johnelliott commented 6 years ago

Closing because it’s probably just my issue. Don’t have time to investigate further. Sorry for the noise.

Kezzsim commented 3 years ago

This is apparently still a real problem Provided module can't be loaded. Did you list all required modules in the package.json dependencies? Detailed stack trace: Error: Cannot find module '../services/pullPsaCredentials'

pullPsaCredentials isn't even a node module, it's just a part of my program. This all runs fine in the emulator so I have no idea why it wouldn't just work.

I need to deploy this project now so I'm just gonna zip it and ship it. But really this shouldn't be happening, it isn't even an npm node module it's just a file

rollinsafary-inomma commented 3 years ago

@johnelliott you aren't alone :D

codin-play commented 3 years ago

@johnelliott you aren't alone :D

Ok I spent about 2 days on this pain and figured it out. The issue is ONLY based on the naming. You cannot have camelcase or uppercase file names in the paths. So so so stupid.

So, rename your filenames to lower case (and directories, remove dashes) and change your imports to follow.

After that, all is good.

johnelliott commented 3 years ago

Wow, it's a party. The machine I did this on is off and unavailable to me right now. Anyone else want to share some similar dumps so we can help the firebase team see if this is something they can help with?

codin-play commented 3 years ago

Wow, it's a party. The machine I did this on is off and unavailable to me right now. Anyone else want to share some similar dumps so we can help the firebase team see if this is something they can help with?

Yup, do I went from this:

@my-custom-dependency/common-datasources/dist/fireStoreHelpers

import {
   A,
   B
 }  from '@my-custom-dependency/common-datasources/dist/fireStoreHelpers';

to:

@my-custom-dependency/common-datasources/dist/firestorehelpers

import {
   A,
   B
 }  from '@my-custom-dependency/common-datasources/dist/firestorehelpers';

I figured it was something with my build systems and all sorts of stuff. But, alas - this was the "issue".

trex-quo commented 3 years ago

This is happening to me, but with an actual package, in fact it's firebase-tools Detailed stack trace: Error: Cannot find module 'firebase-tools'

The package is installed and is definitely present in the package and package-lock files

abeisgoat commented 2 years ago

For folks still experiencing this / issues related to this, please go ahead and open new bugs. It's hard to track this due to the age of the bug.

Awais6 commented 1 year ago

@johnelliott you aren't alone :D

Ok I spent about 2 days on this pain and figured it out. The issue is ONLY based on the naming. You cannot have camelcase or uppercase file names in the paths. So so so stupid.

So, rename your filenames to lower case (and directories, remove dashes) and change your imports to follow.

After that, all is good.

Thank you so much. exactly so stupid error, It has resolved just by renaming my directories to small letters

johnelliott commented 1 year ago

Thank you @taeold 👍