使用foundation-cli创建项目时,如果当前的node版本是12的话就会出现如下错误:

fs.js:27
const { Math, Object } = primordials;
^ ReferenceError: primordials is not defined
at fs.js:27:26

此时需要将node版本切换为10,可安装n这个npm包来实现在一台电脑上运行多个node版本.

node版本切换为10后,再运行创建项目命令,又会出现如下错误:

npm ERR! git rev-list -n1 4.0: fatal: ambiguous argument '4.0': unknown revision or path not in the working tree.
npm ERR! git rev-list -n1 4.0: Use '--' to separate paths from revisions, like this:
npm ERR! git rev-list -n1 4.0: 'git <command> [<revision>...] -- [<file>...]'
npm ERR! git rev-list -n1 4.0:
npm ERR! git rev-list -n1 4.0: fatal: ambiguous argument '4.0': unknown revision or path not in the working tree.
npm ERR! git rev-list -n1 4.0: Use '--' to separate paths from revisions, like this:
npm ERR! git rev-list -n1 4.0: 'git <command> [<revision>...] -- [<file>...]'
npm ERR! git rev-list -n1 4.0:
npm ERR! git clone --template=/home/dev/.npm/_git-remotes/_templates --mirror git@github.com:gulpjs/gulp-cli.git /home/dev/.npm/_git-remotes/git-github-com-gulpjs-gulp-cli-git-15c23bd3: Cloning into bare repository '/home/dev/.npm/_git-remotes/git-github-com-gulpjs-gulp-cli-git-15c23bd3'...
npm ERR! git clone --template=/home/dev/.npm/_git-remotes/_templates --mirror git@github.com:gulpjs/gulp-cli.git /home/dev/.npm/_git-remotes/git-github-com-gulpjs-gulp-cli-git-15c23bd3: Permission denied (publickey).
npm ERR! git clone --template=/home/dev/.npm/_git-remotes/_templates --mirror git@github.com:gulpjs/gulp-cli.git /home/dev/.npm/_git-remotes/git-github-com-gulpjs-gulp-cli-git-15c23bd3: fatal: Could not read from remote repository.
npm ERR! git clone --template=/home/dev/.npm/_git-remotes/_templates --mirror git@github.com:gulpjs/gulp-cli.git /home/dev/.npm/_git-remotes/git-github-com-gulpjs-gulp-cli-git-15c23bd3:
npm ERR! git clone --template=/home/dev/.npm/_git-remotes/_templates --mirror git@github.com:gulpjs/gulp-cli.git /home/dev/.npm/_git-remotes/git-github-com-gulpjs-gulp-cli-git-15c23bd3: Please make sure you have the correct access rights
npm ERR! git clone --template=/home/dev/.npm/_git-remotes/_templates --mirror git@github.com:gulpjs/gulp-cli.git /home/dev/.npm/_git-remotes/git-github-com-gulpjs-gulp-cli-git-15c23bd3: and the repository exists.

这时候需要修改文件中的package.json文件devDependencies节点下的gulp属性,修改后的gulp字段值如下:

 "gulp": "git+https://github.com/gulpjs/gulp#v4.0.0",

手动输入npm i来安装项目文件,这时可能又会出现如下错误:

phantomjs-prebuilt@2.1.14 install /Users/will/work/my-project/node_modules/phantomjs-prebuilt
> node install.js PhantomJS not found on PATH
Downloading https://github.com/Medium/phantomjs/releases/download/v2.1.1/phantomjs-2.1.1-macosx.zip
Saving to /var/folders/mh/2ptfthxj2qb49jscj1b0gjsm0000gn/T/phantomjs/phantomjs-2.1.1-macosx.zip
Receiving... Error making request.
Error: connect ETIMEDOUT 54.231.113.227:443
at Object.exports._errnoException (util.js:1018:11)
at exports._exceptionWithHostPort (util.js:1041:20)
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1090:14)

这是天朝网络的原因:它的安装过程中要去 github 下载一个包,而 github release 文件放在亚马逊 aws 上(被墙了)。解决方法是借助淘宝镜像 (http://cnpmjs.org/downloadshttps://npm.taobao.org/mirrors/phantomjs/) 安装,输入以下命令:

PHANTOMJS_CDNURL=https://npm.taobao.org/mirrors/phantomjs npm install phantomjs-prebuilt

同样安装 node-sass 也会出现类似的问题,解决方法依然是淘宝镜像:

SASS_BINARY_SITE=https://npm.taobao.org/mirrors/node-sass npm install node-sass

如果不想每次都输入前面变量可以将它们写入 ~/.npmrc 文件中

foundation-cli创建项目出错的解决方案的更多相关文章

  1. 解决@vue/cli 创建项目是安装chromedriver时失败的问题

    最近在使用新版vue的命令行工具创建项目时,安装chromedriver老是失败,导致后面的步骤也没有进行.网上搜索了一下,全是使用 工作中常见问题汇总及解决方案 npm install chrome ...

  2. mysql编程--创建函数出错的解决方案

    本文章转载自:http://www.jb51.net/article/71100.htm 在使用MySQL数据库时,有时会遇到MySQL函数不能创建的情况.下面就教您一个解决MySQL函数不能创建问题 ...

  3. Vue CLI 创建项目

    使用命令创建VUE项目 运行以下命令[vue create [项目名]]来创建一个新项目: vue create hello-world 警告 如果你在 Windows 上通过 minTTY 使用 G ...

  4. 2018.5.18 AndroidStudio创建项目出错

    Android Studio 出现 Gradle's dependency cache may be corrupt 错误分析 Error:Failed to open zip file. Gradl ...

  5. 项目从.net core 2.1.0升级到.net core 2.2.4,原有项目出错及解决方案

    ... 1.Controller中的形参命名为query.pager,且里面实体中的参数也有Query.Pager参数时,Query.Pager 就会无数据. 解决方案: 形参query.pager ...

  6. eclipse自动创建项目出错Cannot change version of project facet Dynamic Web Module to 2.3.

    Cannot change version of project facet Dynamic Web Module to 2.3. step1:修改properties step2:修改web.xml ...

  7. vue/cli创建项目过程

            ①vue create demo    vue版本:3.9.3,node版本:12.8.0         ②Manually select features         ③Bab ...

  8. vue cli 3.0快速创建项目

    本地安装vue-cli 前置条件 更新npm到最新版本 命令行运行: npm install -g npmnpm就自动为我们更新到最新版本 淘宝npm镜像使用方法 npm config set reg ...

  9. ASP.NET Core MVC 2.x 全面教程_ASP.NET Core MVC 01. 创建项目 +项目结构和配置简介

    新建项目:Tutotial.Web 解决方案名称可以把web去掉 视频里面把git这个选项勾选了.我就不勾选了 dotnet CLI创建项目 首先必须安装好了.net Core的SDK dotnet ...

随机推荐

  1. curl抓取页面时遇到重定向的解决方法

    用php的curl抓取网页遇到了问题,为阐述方便,将代码简化如下: <?php function curlGet($url) { $ch = curl_init(); curl_setopt($ ...

  2. Deep-learning augmented RNA-seq analysis of transcript splicing | 用深度学习预测可变剪切

    可变剪切的预测已经很流行了,目前主要有两个流派: 用DNA序列以及variant来预测可变剪切:GeneSplicer.MaxEntScan.dbscSNV.S-CAP.MMSplice.clinVa ...

  3. 动态BGP与静态BGP

    在阿里云上选择ECS的时候,发现有动态BGP和静态BGP区分,静态的要便宜些,搜了下区别如下: 静态BGP路由是指由网络运营商手动配置的路由信息.当网络的拓扑结构或链路的状态发生变化时,运营商需要手动 ...

  4. auto-sklearn

    python机器学习-乳腺癌细胞挖掘(博主亲自录制视频) https://study.163.com/course/introduction.htm?courseId=1005269003&u ...

  5. 关于Linux中nohup.out日志过大问题

    背景,java项目,一般在运行JAVA程序时需要用到nohup命令来实现后台启动日志,默认保存在当前目露nohup.out文件.但是有些程序输出nohup文件会出现过大的情况. 在此解决如下: 1,在 ...

  6. java开源工具包-Jodd框架

    java开源工具包-Jodd框架 /    2019-07-24 Jodd是一个Java工具包和微型框架,Jodd 工具包含一些实用的工具类和小型框架,增强了 JDK 提供很多强大的功能,可以帮助实现 ...

  7. 爬虫中BeautifulSoup4解析器

    CSS 选择器:BeautifulSoup4 和 lxml 一样,Beautiful Soup 也是一个HTML/XML的解析器,主要的功能也是如何解析和提取 HTML/XML 数据. lxml 只会 ...

  8. 30段极简Python代码

    Python 是机器学习最广泛采用的编程语言,它最重要的优势在于编程的易用性.如果读者对基本的 Python 语法已经有一些了解,那么这篇文章可能会给你一些启发.作者简单概览了 30 段代码,它们都是 ...

  9. k8s记录-kube-dns(core-dns)配置(七)

    docker search corednsdocker pull xxx 拉取镜像(根据实际情况选择)docker tag xxx coredns/coredns:latestdocker tag c ...

  10. rqalpha学习-2

    conf = default_config()deep_update(user_config(), conf)deep_update(project_config(), conf)   三种不同级别的 ...