gulp - 使用 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(最新)。
谢谢!
解决方案
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 版本代替了那里的版本。
推荐阅读
- vba - 等待 Exchange 服务器更新完成
- python - Python selenium 使用线程
- jenkins - Jenkins 作业未出现在仪表板 UI 中
- javascript - jQuery 使用 Select 选项删除 HTML 元素
- node.js - 无法读取无服务器框架的 s3sync 插件中的属性“defaultEncoding”
- http-status-code-404 - 新 url /_cypress/setup 在赛普拉斯测试期间以 404 打开
- shell - 如何在 MAC 上使用 sed/awk(不支持 gnu)将单引号添加到仅在单词中间(或除开头之外的任何位置)有点的单词中?
- r - R - 合并/加入并仅在丢失时替换(优先级?)
- c# - 记录器
在 api 控制器中永远不会为空 - angular - 如何在Angular中声明一个值可以改变的全局变量?