19

Getting an error when creating a Foundation Zurb project. Tried to solve using the previous suggestions shown for other applications, but none are working.

A post referenced updating elm, and I did so, however, it did not work. Additionally, I reviewed the closed issue for Gulp 3 (i am using gulp 4), but there was not viable fixes (Gulp 3 is broken on Node 12 #2324) or workarounds.

$ foundation new --framework emails
fs.js:27
const { Math, Object } = primordials;
                         ^

ReferenceError: primordials is not defined
    at fs.js:27:26
    at req_ (/usr/lib/node_modules/foundation-cli/node_modules/natives/index.js:143:24)
    at Object.req [as require] (/usr/lib/node_modules/foundation-cli/node_modules/natives/index.js:55:10)
    at Object.<anonymous> (/usr/lib/node_modules/foundation-cli/node_modules/graceful-fs/fs.js:1:37)
    at Module._compile (internal/modules/cjs/loader.js:759:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:770:10)
    at Module.load (internal/modules/cjs/loader.js:628:32)
    at Function.Module._load (internal/modules/cjs/loader.js:555:12)
    at Module.require (internal/modules/cjs/loader.js:666:19)
    at require (internal/modules/cjs/helpers.js:16:16)

I expect the project to build.

Leigh277
  • 191
  • 1
  • 1
  • 6
  • Is this a crosspost of https://github.com/zurb/foundation-sites/issues/11755? –  May 22 '19 at 09:46

2 Answers2

21

I guess you use NodeJS 12 or newer.
NodeJS 12 (and newer) is (currenctly) not supported by the current CLI. Please use NodeJS 10.

You can switch to NodeJS 10 using nvm, n, nodenv or any other solution for managing NodeJS versions.

primordials is part of the natives package and called in the graceful-fs package as you can see in the stacktrace.

You can try to upgrade the graceful-fs dependency from 3 to 4 but this might not work without other changes.

This is in fs.js of graceful-fs 3:

module.exports = require('natives').require('fs', ['stream'])

From the natives page on npmjs.com:

This package has been deprecated Author message:

This module relies on Node.js's internals and will break at some point. Do not use it, and update to graceful-fs@4.x.

Also see https://travis-ci.com/DanielRuf/foundation-cli-test/builds/112738932

enter image description here

enter image description here

Compare this to the environment where we have NodeJS 10 (the team of gulp has deleted the 4.0 tag, you can change the line in package.json to reference gulp 4.0.0):

enter image description here

  • 2
    I could solve switching to 10.x by installing `nvm`, which also helps me switch back to any other node versions as I need. – seniorpreacher Nov 11 '19 at 15:52
  • 1
    Right, you can use n, nvm, nodenv, ... I'm glad that this solved your problem. –  Nov 11 '19 at 19:43
  • As of 27 Sept 2021 (and Foundation 6.7.2) this is the absolute correct answer. I upvoted both the question and the answer because it is correct, clear, easy and fast and if it had more upvotes it would have shown up higher in my searches and I wouldn't have wasted 20 hours struggling to get Foundation 6.7.x working. – adam-asdf Sep 27 '21 at 07:52
10

Works for me using the Manual Setup (node v13.7.0)

To manually set up the template, first download it with Git:

git clone https://github.com/zurb/foundation-emails-template "projectname"

Then open the folder in your command line, and install the needed dependencies:

cd projectname

npm install
M. Edium
  • 111
  • 1
  • 2