“Foundation - ReferenceError:启动基础 zurb 项目时未定义原始值。”

Lei*_*277 18 reference referenceerror zurb-foundation gulp

创建 Foundation Zurb 项目时出错。尝试使用之前为其他应用程序显示的建议来解决,但都没有奏效。

一篇提到更新榆树的帖子,我这样做了,但是,它没有用。此外,我查看了 Gulp 3 的已关闭问题(我使用的是 gulp 4),但没有可行的修复(Gulp 3 在 Node 12 #2324 上被破坏)或解决方法。

$ 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)
Run Code Online (Sandbox Code Playgroud)

我希望该项目能够建立。

Dan*_*Ruf 19

我猜您使用的是 NodeJS 12。
当前的 CLI 不支持 NodeJS 12。请使用 NodeJS 10。

您可以使用 nvm、n、nodeenv 或任何其他管理 NodeJS 版本的解决方案切换到 NodeJS 10。

primordialsnatives包的一部分并在包中调用,graceful-fs如您在堆栈跟踪中所见。

您可以尝试将graceful-fs依赖项从 3升级到 4,但如果没有其他更改,这可能无法正常工作。

这是在 fs.js 中的graceful-fs3:

module.exports = require('natives').require('fs', ['stream'])
Run Code Online (Sandbox Code Playgroud)

npmjs.comnatives上的页面:

这个包已被弃用 作者信息:

这个模块依赖于 Node.js 的内部结构,并且会在某个时候中断。不要使用它,并更新到graceful-fs@4.x。

另见https://travis-ci.com/DanielRuf/foundation-cli-test/builds/112738932

在此处输入图片说明

在此处输入图片说明

将此与我们有NodeJS 10的环境进行比较(gulp团队删除了4.0标签,您可以将package.json中的行更改为引用gulp 4.0.0):

在此处输入图片说明

  • 我可以通过安装 `nvm` 来解决切换到 10.x 的问题,这也可以帮助我根据需要切换回任何其他节点版本。 (2认同)

小智 9

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"
Run Code Online (Sandbox Code Playgroud)

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

cd projectname

npm install
Run Code Online (Sandbox Code Playgroud)