首页 > 解决方案 > 使用 Foundations 运行“npm start”和“npm install gulp”时出错

问题描述

我是 Foundation for Emails 的新手,我只是想按照指示一步一步安装所有东西。我已经安装了 Git 和 Node.js(最新版本 11.5.0)。

我创建了我的项目目录(test123),并在里面告诉我运行“npm start”。我这样做并得到以下错误:

Alexandrus-MacBook-Pro-2:test123 alexcrisan$ npm start

> foundation-emails-template@1.0.0 start. /Users/alexcrisan/Documents/sites/test123
> gulp

[09:27:55] Failed to load external module @babel/register
[09:27:55] Failed to load external module babel-register
[09:27:55] Failed to load external module babel-core/register
[09:27:55] Failed to load external module babel/register
[09:27:55] Local gulp not found in ~/Documents/sites/test123
[09:27:55] Try running: npm install gulp
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! foundation-emails-template@1.0.0 start: `gulp`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the foundation-emails-template@1.0.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm WARN Local package.json exists, but node_modules missing, did you mean to install?

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/alexcrisan/.npm/_logs/2018-12-26T14_27_55_973Z-debug.log

我按照错误代码安装 gulp,得到这个:

Alexandrus-MacBook-Pro-2:test123 alexcrisan$ npm install gulp
npm ERR! code 1
npm ERR! Command failed: /usr/bin/git checkout 4.0
npm ERR! error: pathspec '4.0' did not match any file(s) known to git.
npm ERR! 

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/alexcrisan/.npm/_logs/2018-12-26T15_03_01_008Z-debug.log

我在网上找到了一些类似的答案,但找不到一种直接的方法来解决这个问题,而不会让自己陷入更多的困惑。

运行 Mac OS Mojave(最新)。

谢谢!

标签: gulpnpm-installzurb-foundation-6npm-start

解决方案


gulp 的 git 版本名称已从 4.0 更改为 v4.0.0,这意味着 git 无法找到安装它的节点模块。

如果你打开你的 package.json,你应该会看到如下内容:

"gulp": "github:gulpjs/gulp#4.0",

将其替换为:

"gulp": "github:gulpjs/gulp#v4.0.0",

然后删除你的 node-modules 文件夹并重新安装,它现在应该可以正常运行了。

我知道你的感受,这让我困惑了一段时间。为了解决这个问题,我查看了 github ( https://github.com/gulpjs/gulp/releases ) 上的已发布版本,并使用 v4.0.0 版本代替了那里的版本。


推荐阅读