Home > Enterprise >  Error running gulp in cordova app because of graceful-js version
Error running gulp in cordova app because of graceful-js version

Time:08-27

I'm trying to build a Cordova app and launching gulp causes the following issue:

ReferenceError: primordials is not defined
    at fs.js:47:5
    at req_ (/home/ubuntu/WebstormProjects/Edilapp/node_modules/natives/index.js:143:24)
    at Object.req [as require] (/home/ubuntu/WebstormProjects/Edilapp/node_modules/natives/index.js:55:10)
    at Object.<anonymous> (/home/ubuntu/WebstormProjects/Edilapp/node_modules/vinyl-fs/node_modules/graceful-fs/fs.js:1:37)
    at Module._compile (node:internal/modules/cjs/loader:1120:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1174:10)
    at Module.load (node:internal/modules/cjs/loader:998:32)
    at Module._load (node:internal/modules/cjs/loader:839:12)
    at Module.require (node:internal/modules/cjs/loader:1022:19)
    at require (node:internal/modules/cjs/helpers:102:18)

In my project, I'd expect to have version 4.2.10, in fact my package.json contains this: "graceful-fs": "4.2.10". Also, if I explore the node_modules/graceful-fs folder, I actually find a README referring to v4 changes, i.e. I have the expected version.

Nevertheless, in package-lock.json file I see that [email protected] is included and it mentions that a version of [email protected] should be used. Similary, in the dependencies section I found glob, requiring "graceful-fs": "~1.2.0" and getting 1.2.3, gulp-cssmin requiring ~2.0.0 and getting 2.0.3, vinyl-fs requiring ~3.0.0 and getting 3.0.12.

This is my full package.json:

{
 "name": "xxxxxxx",
 "version": "3.0",
 "devDependencies": {
 "gulp": "^3.9.1",
 "gulp-angular-filesort": "^1.2.1",
 "gulp-angular-templatecache": "^1.2.1",
 "gulp-concat": "^2.3.4",
 "gulp-connect": "^5.6.1",
 "gulp-cssmin": "^0.1.6",
 "gulp-ignore": "^2.0.2",
 "gulp-less": "^4.0.1",
 "gulp-mobilizer": "^0.0.2",
 "gulp-ng-annotate": "^0.2.0",
 "gulp-open": "^3.0.1",
 "gulp-order": "^1.1.1",
 "gulp-rename": "^1.4.0",
 "gulp-replace": "^0.4.0",
 "gulp-rimraf": "^0.1.0",
 "gulp-sequence": "^0.4.6",
 "gulp-sourcemaps": "^1.12.1",
 "gulp-uglify": "1.5.1",
 "streamqueue": "^0.1.1",
 "weinre": "^2.0.0-pre-I0Z7U9OV"
 },
 "cordova": {
 "plugins": {
 "cordova-plugin-device": {},
 "cordova-plugin-inappbrowser": {},
 "cordova-plugin-whitelist": {},
 "cordova-plugin-file-opener2": {
 "ANDROID_SUPPORT_V4_VERSION": "27. "
 },
 "cordova-plugin-camera": {},
 "cordova-plugin-email-composer": {},
 "cordova-plugin-media-capture": {
 "CAMERA_USAGE_DESCRIPTION": "Richiesta per invio foto a ente di appartenenza.",
 "MICROPHONE_USAGE_DESCRIPTION": "L'app vorrebbe usare il microfono.",
 "PHOTOLIBRARY_USAGE_DESCRIPTION": "Richiesta per invio foto a ente di appartenenza."
 },
 "pushwoosh-cordova-plugin": {
 "LOG_LEVEL": "DEBUG",
 "IOS_FOREGROUND_ALERT_TYPE": "NONE",
 "ANDROID_FOREGROUND_PUSH": "false"
 },
 "Camera": {},
 "cordova-plugin-file-transfer": {},
 "cordova-plugin-file": {},
 "cordova-plugin-androidx": {},
 "cordova-plugin-androidx-adapter": {},
 "cordova-plugin-qrscanner": {},
 "phonegap-nfc": {},
 "org.apache.cordova.geolocation": {},
 "cordova-plugin-geolocation": {}
 },
 "platforms": [
 "browser",
 "ios",
 "android"
 ]
 },
 "dependencies": {
 "cordova-browser": "^6.0.0",
 "cordova-plugin-camera": "^6.0.0",
 "cordova-plugin-compat": "^1.2.0",
 "cordova-plugin-device": "^2.1.0",
 "cordova-plugin-email-composer": "^0.10.1",
 "cordova-plugin-file": "^7.0.0",
 "cordova-plugin-file-opener2": "^3.0.5",
 "cordova-plugin-file-transfer": "^1.7.1",
 "cordova-plugin-geolocation": "^4.1.0",
 "cordova-plugin-inappbrowser": "^5.0.0",
 "cordova-plugin-media-capture": "^4.0.0",
 "cordova-plugin-qrscanner": "^3.0.1",
 "cordova-plugin-whitelist": "^1.3.5",
 "graceful-fs": "4.2.10",
 "phonegap-nfc": "^1.2.0",
 "www": "0.0.0"
 }
}

Node version: 18.7.0 Npm version: 8.18.0 Gulp cli version: 2.3.0 Gulp locale version: 3.9.1

How can I proceed?

CodePudding user response:

Bruteforce solution: removed all versions package json except the constrained ones, then reinstalled every single dependency. It worked.

  • Related