megclaypool
1/30/2019 - 8:04 PM

Fix for weird gulp error

[Fix for weird gulp error]

Problem

 ⚡ gulp css      
fs.js:35
} = primordials;
    ^

ReferenceError: primordials is not defined
    at fs.js:35:5
    at req_ (/Users/noxlady/Sites/american-rivers/wp-content/themes/base-theme/node_modules/natives/index.js:143:24)
    at Object.req [as require] (/Users/noxlady/Sites/american-rivers/wp-content/themes/base-theme/node_modules/natives/index.js:55:10)
    at Object.<anonymous> (/Users/noxlady/Sites/american-rivers/wp-content/themes/base-theme/node_modules/graceful-fs/fs.js:1:37)
    at Module._compile (internal/modules/cjs/loader.js:1138:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1158:10)
    at Module.load (internal/modules/cjs/loader.js:986:32)
    at Function.Module._load (internal/modules/cjs/loader.js:879:14)
    at Module.require (internal/modules/cjs/loader.js:1026:19)
    at require (internal/modules/cjs/helpers.js:72:18)

Solution (from StackOverflow)

I hit the same error. I suspect you're using node 12 and gulp 3. That combination does not work: https://github.com/gulpjs/gulp/issues/2324

A previous workaround from Jan. does not work either: https://github.com/gulpjs/gulp/issues/2246

Solution: Either upgrade to gulp 4 or downgrade to an earlier node.

Similar to this person on GitHub

I am running MacOS 10.13.6 and use Homebrew to keep Node and NPM up to date. I've updated to Node '11.0.0' and NPM '6.4.1' today. I've installed Gulp '3.9.1' globally. When i try to run Gulp in my project folder i get the following error (before '11.0.0' everything worked flawlessly):

$> gulp
fs.js:25
'use strict';
^

ReferenceError: internalBinding is not defined
    at fs.js:25:1
    at req_ (/Users/danton/SitesLocal/myapp/app/public/node_modules/natives/index.js:140:5)
    at Object.req [as require] (/Users/danton/SitesLocal/myapp/app/public/node_modules/natives/index.js:54:10)
    at Object.<anonymous> (/Users/danton/SitesLocal/myapp/app/public/node_modules/graceful-fs/fs.js:1:99)
    at Module._compile (internal/modules/cjs/loader.js:707:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:718:10)
    at Module.load (internal/modules/cjs/loader.js:605:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:544:12)
    at Function.Module._load (internal/modules/cjs/loader.js:536:3)
    at Module.require (internal/modules/cjs/loader.js:643:17)

Solution:

npm install natives@1.1.6