Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

Cloud Function : NPM Errors

Hello all,

Iam trying hard to three days to deploy my first function , but whenever i deploy the function i get this npm error below.

i even used the required node version 18.17.0 but it didn't work and kept saying "This function has failed to deploy and will not work correctly."

 

please someone help


Build failed with status: FAILURE and message: npm ERR! code EUSAGE npm ERR! npm ERR! `npm ci` can only install packages when your package.json and package-lock.json or npm-shrinkwrap.json are in sync. Please update your lock file with `npm install` before continuing. npm ERR! npm ERR! Missing: jest@29.7.0 from lock file npm ERR! Missing: @jest/core@29.7.0 from lock file npm ERR! Missing: @jest/types@29.6.3 from lock file npm ERR! Missing: import-local@3.1.0 from lock file npm ERR! Missing: jest-cli@29.7.0 from lock file npm ERR! Missing: @jest/console@29.7.0 from lock file npm ERR! Missing: @jest/reporters@29.7.0 from lock file npm ERR! Missing: @jest/test-result@29.7.0 from lock file npm ERR! Missing: @jest/transform@29.7.0 from lock file npm ERR! Missing: ansi-escapes@4.3.2 from lock file npm ERR! Missing: ci-info@3.9.0 from lock file npm ERR! Missing: exit@0.1.2 from lock file npm ERR! Missing: jest-changed-files@29.7.0 from lock file npm ERR! Missing: jest-config@29.7.0 from lock file npm ERR! Missing: jest-haste-map@29.7.0 from lock file npm ERR! Missing: jest-message-util@29.7.0 from lock file npm ERR! Missing: jest-regex-util@29.6.3 from lock file npm ERR! Missing: jest-resolve@29.7.0 from lock file npm ERR! Missing: jest-resolve-dependencies@29.7.0 from lock file npm ERR! Missing: jest-runner@29.7.0 from lock file npm ERR! Missing: jest-runtime@29.7.0 from lock file npm ERR! Missing: jest-snapshot@29.7.0 from lock file npm ERR! Missing: jest-util@29.7.0 from lock file npm ERR! Missing: jest-validate@29.7.0 from lock file npm ERR! Missing: jest-watcher@29.7.0 from lock file npm ERR! Missing: micromatch@4.0.5 from lock file npm ERR! Missing: pretty-format@29.7.0 from lock file npm ERR! Missing: slash@3.0.0 from lock file npm ERR! Missing: @bcoe/v8-coverage@0.2.3 from lock file npm ERR! Missing: @jridgewell/trace-mapping@0.3.25 from lock file npm ERR! Missing: collect-v8-coverage@1.0.2 from lock file npm ERR! Missing: glob@7.2.3 from lock file npm ERR! Missing: istanbul-lib-coverage@3.2.2 from lock file npm ERR! Missing: istanbul-lib-instrument@6.0.2 from lock file npm ERR! Missing: istanbul-lib-report@3.0.1 from lock file npm ERR! Missing: istanbul-lib-source-maps@4.0.1 from lock file npm ERR! Missing: istanbul-reports@3.1.7 from lock file npm ERR! Missing: jest-worker@29.7.0 from lock file npm ERR! Missing: string-length@4.0.2 from lock file npm ERR! Missing: v8-to-istanbul@9.2.0 from lock file npm ERR! Missing: @types/istanbul-lib-coverage@2.0.6 from lock file npm ERR! Missing: @babel/core@7.24.0 from lock file npm ERR! Missing: babel-plugin-istanbul@6.1.1 from lock file npm ERR! Missing: convert-source-map@2.0.0 from lock file npm ERR! Missing: pirates@4.0.6 from lock file npm ERR! Missing: write-file-atomic@4.0.2 from lock file npm ERR! Missing: @ampproject/remapping@2.3.0 from lock file npm ERR! Missing: @babel/code-frame@7.23.5 from lock file npm ERR! Missing: @babel/generator@7.23.6 from lock file npm ERR! Missing: @babel/helper-compilation-targets@7.23.6 from lock file npm ERR! Missing: @babel/helper-module-transforms@7.23.3 from lock file npm ERR! Missing: @babel/helpers@7.24.0 from lock file npm ERR! Missing: @babel/template@7.24.0 from lock file npm ERR! Missing: @babel/traverse@7.24.0 from lock file npm ERR! Missing: @babel/types@7.24.0 from lock file npm ERR! Missing: gensync@1.0.0-beta.2 from lock file npm ERR! Missing: json5@2.2.3 from lock file npm ERR! Missing: semver@6.3.1 from lock file npm ERR! Missing: @jridgewell/gen-mapping@0.3.5 from lock file npm ERR! Missing: @babel/highlight@7.23.4 from lock file npm ERR! Missing: chalk@2.4.2 from lock file npm ERR! Missing: jsesc@2.5.2 from lock file npm ERR! Missing: @babel/compat-data@7.23.5 from lock file npm ERR! Missing: @babel/helper-validator-option@7.23.5 from lock file npm ERR! Missing: browserslist@4.23.0 from lock file npm ERR! Missing: lru-cache@5.1.1 from lock file npm ERR! Missing: semver@6.3.1 from lock file npm ERR! Missing: @babel/helper-environment-visitor@7.22.20 from lock file npm ERR! Missing: @babel/helper-module-imports@7.22.15 from lock file npm ERR! Missing: @babel/helper-simple-access@7.22.5 from lock file npm ERR! Missing: @babel/helper-split-export-declaration@7.22.6 from lock file npm ERR! Missing: @babel/helper-validator-identifier@7.22.20 from lock file npm ERR! Missing: chalk@2.4.2 from lock file npm ERR! Missing: js-tokens@4.0.0 from lock file npm ERR! Missing: @babel/helper-function-name@7.23.0 from lock file npm ERR! Missing: @babel/helper-hoist-variables@7.22.5 from lock file npm ERR! Missing: globals@11.12.0 from lock file npm ERR! Missing: @babel/helper-string-parser@7.23.4 from lock file npm ERR! Missing: to-fast-properties@2.0.0 from lock file npm ERR! Missing: @jest/schemas@29.6.3 from lock file npm ERR! Missing: @types/istanbul-reports@3.0.4 from lock file npm ERR! Missing: @types/yargs@17.0.32 from lock file npm ERR! Missing: @sinclair/typebox@0.27.8 from lock file npm ERR! Missing: @jridgewell/set-array@1.2.1 from lock file npm ERR! Missing: @jridgewell/sourcemap-codec@1.4.15 from lock file npm ERR! Missing: @jridgewell/resolve-uri@3.1.2 from lock file npm ERR! Missing: @types/istanbul-lib-report@3.0.3 from lock file npm ERR! Missing: @types/yargs-parser@21.0.3 from lock file npm ERR! Missing: type-fest@0.21.3 from lock file npm ERR! Missing: @babel/helper-plugin-utils@7.24.0 from lock file npm ERR! Missing: @istanbuljs/load-nyc-config@1.1.0 from lock file npm ERR! Missing: @istanbuljs/schema@0.1.3 from lock file npm ERR! Missing: istanbul-lib-instrument@5.2.1 from lock file npm ERR! Missing: test-exclude@6.0.0 from lock file npm ERR! Missing: camelcase@5.3.1 from lock file npm ERR! Missing: find-up@4.1.0 from lock file npm ERR! Missing: get-package-type@0.1.0 from lock file npm ERR! Missing: js-yaml@3.14.1 from lock file npm ERR! Missing: resolve-from@5.0.0 from lock file npm ERR! Missing: caniuse-lite@1.0.30001597 from lock file npm ERR! Missing: electron-to-chromium@1.4.704 from lock file npm ERR! Missing: node-releases@2.0.14 from lock file npm ERR! Missing: update-browserslist-db@1.0.13 from lock file npm ERR! Missing: pkg-dir@4.2.0 from lock file npm ERR! Missing: resolve-cwd@3.0.0 from lock file npm ERR! Missing: make-dir@4.0.0 from lock file npm ERR! Missing: html-escaper@2.0.2 from lock file npm ERR! Missing: execa@5.1.1 from lock file npm ERR! Missing: get-stream@6.0.1 from lock file npm ERR! Missing: human-signals@2.1.0 from lock file npm ERR! Missing: merge-stream@2.0.0 from lock file npm ERR! Missing: npm-run-path@4.0.1 from lock file npm ERR! Missing: onetime@5.1.2 from lock file npm ERR! Missing: signal-exit@3.0.7 from lock file npm ERR! Missing: strip-final-newline@2.0.0 from lock file npm ERR! Missing: create-jest@29.7.0 from lock file npm ERR! Missing: prompts@2.4.2 from lock file npm ERR! Missing: @jest/test-sequencer@29.7.0 from lock file npm ERR! Missing: babel-jest@29.7.0 from lock file npm ERR! Missing: deepmerge@4.3.1 from lock file npm ERR! Missing: glob@7.2.3 from lock file npm ERR! Missing: jest-circus@29.7.0 from lock file npm ERR! Missing: jest-environment-node@29.7.0 from lock file npm ERR! Missing: jest-get-type@29.6.3 from lock file npm ERR! Missing: parse-json@5.2.0 from lock file npm ERR! Missing: @types/babel__core@7.20.5 from lock file npm ERR! Missing: babel-preset-jest@29.6.3 from lock file npm ERR! Missing: @types/babel__generator@7.6.8 from lock file npm ERR! Missing: @types/babel__template@7.4.4 from lock file npm ERR! Missing: @types/babel__traverse@7.20.5 from lock file npm ERR! Missing: babel-plugin-jest-hoist@29.6.3 from lock file npm ERR! Missing: babel-preset-current-node-syntax@1.0.1 from lock file npm ERR! Missing: @babel/plugin-syntax-async-generators@7.8.4 from lock file npm ERR! Missing: @babel/plugin-syntax-bigint@7.8.3 from lock file npm ERR! Missing: @babel/plugin-syntax-class-properties@7.12.13 from lock file npm ERR! Missing: @babel/plugin-syntax-import-meta@7.10.4 from lock file npm ERR! Missing: @babel/plugin-syntax-json-strings@7.8.3 from lock file npm ERR! Missing: @babel/plugin-syntax-logical-assignment-operators@7.10.4 from lock file npm ERR! Missing: @babel/plugin-syntax-nullish-coalescing-operator@7.8.3 from lock file npm ERR! Missing: @babel/plugin-syntax-numeric-separator@7.10.4 from lock file npm ERR! Missing: @babel/plugin-syntax-object-rest-spread@7.8.3 from lock file npm ERR! Missing: @babel/plugin-syntax-optional-catch-binding@7.8.3 from lock file npm ERR! Missing: @babel/plugin-syntax-optional-chaining@7.8.3 from lock file npm ERR! Missing: @babel/plugin-syntax-top-level-await@7.14.5 from lock file npm ERR! Missing: @jest/environment@29.7.0 from lock file npm ERR! Missing: @jest/expect@29.7.0 from lock file npm ERR! Missing: co@4.6.0 from lock file npm ERR! Missing: dedent@1.5.1 from lock file npm ERR! Missing: is-generator-fn@2.1.0 from lock file npm ERR! Missing: jest-each@29.7.0 from lock file npm ERR! Missing: jest-matcher-utils@29.7.0 from lock file npm ERR! Missing: pure-rand@6.0.4 from lock file npm ERR! Missing: stack-utils@2.0.6 from lock file npm ERR! Missing: @jest/fake-timers@29.7.0 from lock file npm ERR! Missing: jest-mock@29.7.0 from lock file npm ERR! Missing: expect@29.7.0 from lock file npm ERR! Missing: @sinonjs/fake-timers@10.3.0 from lock file npm ERR! Missing: @sinonjs/commons@3.0.1 from lock file npm ERR! Missing: type-detect@4.0.8 from lock file npm ERR! Missing: @jest/expect-utils@29.7.0 from lock file npm ERR! Missing: @types/graceful-fs@4.1.9 from lock file npm ERR! Missing: anymatch@3.1.3 from lock file npm ERR! Missing: fb-watchman@2.0.2 from lock file npm ERR! Missing: fsevents@2.3.3 from lock file npm ERR! Missing: walker@1.0.8 from lock file npm ERR! Missing: normalize-path@3.0.0 from lock file npm ERR! Missing: picomatch@2.3.1 from lock file npm ERR! Missing: bser@2.1.1 from lock file npm ERR! Missing: node-int64@0.4.0 from lock file npm ERR! Missing: jest-diff@29.7.0 from lock file npm ERR! Missing: diff-sequences@29.6.3 from lock file npm ERR! Missing: @types/stack-utils@2.0.3 from lock file npm ERR! Missing: jest-pnp-resolver@1.2.3 from lock file npm ERR! Missing: resolve@1.22.8 from lock file npm ERR! Missing: resolve.exports@2.0.2 from lock file npm ERR! Missing: emittery@0.13.1 from lock file npm ERR! Missing: jest-docblock@29.7.0 from lock file npm ERR! Missing: jest-leak-detector@29.7.0 from lock file npm ERR! Missing: source-map-support@0.5.13 from lock file npm ERR! Missing: detect-newline@3.1.0 from lock file npm ERR! Missing: @jest/globals@29.7.0 from lock file npm ERR! Missing: @jest/source-map@29.6.3 from lock file npm ERR! Missing: cjs-module-lexer@1.2.3 from lock file npm ERR! Missing: glob@7.2.3 from lock file npm ERR! Missing: strip-bom@4.0.0 from lock file npm ERR! Missing: @babel/plugin-syntax-jsx@7.23.3 from lock file npm ERR! Missing: @babel/plugin-syntax-typescript@7.23.3 from lock file npm ERR! Missing: camelcase@6.3.0 from lock file npm ERR! Missing: leven@3.1.0 from lock file npm ERR! Missing: supports-color@8.1.1 from lock file npm ERR! Missing: braces@3.0.2 from lock file npm ERR! Missing: fill-range@7.0.1 from lock file npm ERR! Missing: to-regex-range@5.0.1 from lock file npm ERR! Missing: mimic-fn@2.1.0 from lock file npm ERR! Missing: error-ex@1.3.2 from lock file npm ERR! Missing: json-parse-even-better-errors@2.3.1 from lock file npm ERR! Missing: lines-and-columns@1.2.4 from lock file npm ERR! Missing: is-arrayish@0.2.1 from lock file npm ERR! Missing: find-up@4.1.0 from lock file npm ERR! Missing: ansi-styles@5.2.0 from lock file npm ERR! Missing: react-is@18.2.0 from lock file npm ERR! Missing: kleur@3.0.3 from lock file npm ERR! Missing: sisteransi@1.0.5 from lock file npm ERR! Missing: is-core-module@2.13.1 from lock file npm ERR! Missing: path-parse@1.0.7 from lock file npm ERR! Missing: supports-preserve-symlinks-flag@1.0.0 from lock file npm ERR! Missing: resolve-from@5.0.0 from lock file npm ERR! Missing: buffer-from@1.1.2 from lock file npm ERR! Missing: escape-string-regexp@2.0.0 from lock file npm ERR! Missing: char-regex@1.0.2 from lock file npm ERR! Missing: glob@7.2.3 from lock file npm ERR! Missing: is-number@7.0.0 from lock file npm ERR! Missing: picocolors@1.0.0 from lock file npm ERR! Missing: makeerror@1.0.12 from lock file npm ERR! Missing: tmpl@1.0.5 from lock file npm ERR! Missing: ansi-styles@3.2.1 from lock file npm ERR! Missing: escape-string-regexp@1.0.5 from lock file npm ERR! Missing: supports-color@5.5.0 from lock file npm ERR! Missing: color-convert@1.9.3 from lock file npm ERR! Missing: color-name@1.1.3 from lock file npm ERR! Missing: has-flag@3.0.0 from lock file npm ERR! Missing: yallist@3.1.1 from lock file npm ERR! Missing: ansi-styles@3.2.1 from lock file npm ERR! Missing: escape-string-regexp@1.0.5 from lock file npm ERR! Missing: supports-color@5.5.0 from lock file npm ERR! Missing: color-convert@1.9.3 from lock file npm ERR! Missing: color-name@1.1.3 from lock file npm ERR! Missing: has-flag@3.0.0 from lock file npm ERR! Missing: locate-path@5.0.0 from lock file npm ERR! Missing: argparse@1.0.10 from lock file npm ERR! Missing: sprintf-js@1.0.3 from lock file npm ERR! Missing: p-locate@4.1.0 from lock file npm ERR! Missing: p-limit@2.3.0 from lock file npm ERR! Missing: p-try@2.2.0 from lock file npm ERR! Missing: semver@6.3.1 from lock file npm ERR! Missing: locate-path@5.0.0 from lock file npm ERR! Missing: p-locate@4.1.0 from lock file npm ERR! Missing: p-limit@2.3.0 from lock file npm ERR! npm ERR! Clean install a project npm ERR! npm ERR! Usage: npm ERR! npm ci npm ERR! npm ERR! Options: npm ERR! [--install-strategy <hoisted|nested|shallow|linked>] [--legacy-bundling] npm ERR! [--global-style] [--omit <dev|optional|peer> [--omit <dev|optional|peer> ...]] npm ERR! [--include <prod|dev|optional|peer> [--include <prod|dev|optional|peer> ...]] npm ERR! [--strict-peer-deps] [--foreground-scripts] [--ignore-scripts] [--no-audit] npm ERR! [--no-bin-links] [--no-fund] [--dry-run] npm ERR! [-w|--workspace <workspace-name> [-w|--workspace <workspace-name> ...]] npm ERR! [-ws|--workspaces] [--include-workspace-root] [--install-links] npm ERR! npm ERR! aliases: clean-install, ic, install-clean, isntall-clean npm ERR! npm ERR! Run "npm help ci" for more info npm ERR! A complete log of this run can be found in: /www-data-home/.npm/_logs/2024-03-14T10_57_07_831Z-debug-0.log. For more details see the logs at https://console.cloud.google.com/cloud-build/builds;region=us-central1/81ea8881-7c33-4716-ba89-c0b4c....

0 1 348
1 REPLY 1

Hello @BahaniBillel,

Welcome to Google Cloud Community!

You can do the following troubleshooting options:

  1. Check out the documentation on how to create and deploy an HTTP Cloud Function with Node.js
  2. The error usually occurs if you don't use npm install for installing dependencies. See Specify dependencies in Node.js

Also, take a look at these related Stackoverflow posts as you might have the same issue:

If the above options don't work, you can contact Google Cloud Support to further look into your case. Hope it helps, thanks!