Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

299
Views
How to prevent babel/cli not accessible error when deploying to Google Cloud?

I have a Node.js Google cloud function which I now try to modularize into two js modules. It works fine locally on my machine but when trying to deploy to Google I get the following error:

ERROR: (gcloud.functions.deploy) OperationError: code=3, message=Build failed: npm ERR! @babel/cli not accessible from data-model

My main-function is using my data-model module via the following entry in package.json:

  "dependencies": {
    "@google-cloud/datastore": "^6.1.1",
    "data-model": "file:../../data-model",
    ...
  },

The data-model module in turn has the following package.json:

{
  "name": "data-model",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "$(gcloud beta emulators datastore env-unset) && export GOOGLE_APPLICATION_CREDENTIALS=\"${GCPPRODFILEPATH}\" &&  jest --verbose --forceExit",
    "build": "npx babel src --out-dir dist"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "dependencies": {
    "@google-cloud/datastore": "^6.6.2",
    "@google-cloud/storage": "^5.16.1",
    "cache-manager-redis-store": "^2.0.0",
    "difference": "^1.0.2",
    "gstore-node": "^7.2.6",
    "ioredis": "^4.28.2",
    "lodash": "^4.17.21"
  },
  "devDependencies": {
    "@babel/cli": "^7.16.7",
    "@babel/core": "^7.16.7",
    "@babel/plugin-transform-modules-commonjs": "^7.16.5",
    "@babel/plugin-transform-runtime": "^7.16.5",
    "@babel/preset-env": "^7.16.5",
    "jest": "^27.4.5"
  }
}

and the index.js for data-model is just:

module.exports = Object.assign(
    {},
    require('./dist/garage'),
    require('./dist/car'),
    require('./dist/bike'),
    require('./dist/util/cacheService'),
);

I'm very much a novice on npm and babel but my understanding was that when I build data-model to /dist babel would transform whatever needed and when I then use the module from main-function babel should be out of the picture. Clearly my understanding is wrong, but where?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

I finally managed to solve this, got a bit side-tracked by the babel/cli error message that CloudFunction threw.

The issue was that my data-model module was in another directory:
"data-model": "file:../../data-model",

I put it inside the main-function instead:
"data-model": "file:data-model", and it works just fine to deploy to cloud functions.

Why it is so I have no clue but it is kind of documented in the Google Cloud Docs too:

The code for this local module should be stored somewhere other than the node_modules folder within your function's root directory.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!