使用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 文件中

最新文章

  1. ckplayer 如何在PC上完美支持 m3u8播放
  2. 图解HTTP
  3. 测试驱动开发与Python
  4. Python操作RabbitMQ
  5. SQL去除回车符,换行符,空格和水平制表符
  6. 常用iOS的第三方框架
  7. 正确理解静态Static关键字
  8. WCF服务部署到IIS7.5
  9. C++学习笔记15:操作符重载的函数原型列表(推荐)
  10. jquery uploadify修改上传的文件名和显示
  11. homework做了些什么?
  12. (中等) HDU 1495 非常可乐,BFS。
  13. 分30条依次解析xml并插入数据库成功
  14. 《Java程序设计》终极不改版
  15. hadoop集群篇--从0到1搭建hadoop集群
  16. python语言学习笔记整理
  17. Kitty猫基因编码
  18. EscapeAndUnescapeUtil【java模拟js的escape和unescape函数】
  19. 【转】WPF自定义控件与样式(11)-等待/忙/正在加载状态-控件实现
  20. 【Codeforces 1106E】 Lunar New Year and Red Envelopes

热门文章

  1. 原生js实现浏览器全屏和退出全屏
  2. 手把手教你 GitLab 的安装及使用
  3. Java多线程的Semaphore
  4. [转]C++ 使用 curl 进行 http 请求(GET、POST、Download)的封装
  5. Oracle系列五 多表查询
  6. 013-在 Shell 脚本中调用另一个 Shell 脚本的三种方式
  7. 基于ifc数据的bim模型吊装模拟-1
  8. Laya自定义组件
  9. [LeetCode] 712. Minimum ASCII Delete Sum for Two Strings 两个字符串的最小ASCII删除和
  10. 并行执行任务 Stat-Job