搭建gin环境的一些报错

之前做的gin项目,在搭建过程中的报错,简单记录下

1、npm install 报错

Thanks for using Babel: we recommend using babel-preset-env now: please read babeljs.io/env to update!

解决:

原因是babe-preset-es2015已经过时,最新的是 babel-preset-env
首先卸载原来的 preset,然后安装 babel-preset-env:
1
2
npm uninstall --save-dev babel-preset-es2015
npm install --save-dev babel-preset-env@next
接下来将你的 .babelrc 文件中“es2015”修改“env”:
1
2
3
4
{
"presets": [ "env" ],
...
}

failed to fetch from registry:=https://registry.npm.taobao.org/deepmerge

npm config set registry http://registry.npmjs.org/

估计是淘宝的源没有更新,换成官方的

1
npm config set registry http://registry.npmjs.org/

npm WARN ajv-keywords@3.2.0 requires a peer of ajv@^6.0.0 but none was installed.

npm install ajv@^6.0.0

npm WARN iview@2.11.0 requires a peer of vue@^2.5.2 but none was installed.

npm install vue@^2.5.2

Vue packages version mismatch:

Vue packages version mismatch:

  • vue@2.5.16
  • vue-template-compiler@2.4.4
    更新
  • npm update vue-template-compiler
    或者
  • npm uninstall –save-dev vue-loader
  • npm install –save-dev vue-loader
    或者
  • npm uninstall –save-dev vue-template-compiler
  • npm install –save-dev vue-template-compiler

Module parse failed: Unexpected token (91:0) You may need an appropriate loader to handle this file

安装的 vue-loader 版本与package.json中的不匹配

2、配置https

生成证书本地开发的证书可以自己生成一个,可以通过以下步骤生成一个简单的证书:

2.1 首先,进入你想创建证书和私钥的目录,例如:

1
$ cd /usr/local/nginx/conf

2.2 创建服务器私钥,命令会让你输入一个口令:

1
$ openssl genrsa -out privkey.pem 1024/2038

2.3 创建签名请求的证书(CSR):

1
$ openssl req -new -x509 -key privkey.pem -out server.pem -days 365

其他选项可以自由填写
Common name 必须正确填写

go dep安装失败

找到源地址后使用go get 手动安装

goroot配置错误导致的报错

1
2
3
4
vendor/github.com/gin-gonic/gin/response_writer.go:8:2: cannot find package "bufio" in any of:
/Users/taichirain/codeEnv/golang/go/src/gitee.com/orange/vendor/bufio (vendor tree)
/usr/local/opt/go/libexec/bin/src/bufio (from $GOROOT)
/Users/taichirain/codeEnv/golang/go/src/bufio (from $GOPATH)

正确配置一下goroot就好了

1
2
3
4
5
export GOPATH=/Users/taichirain/codeEnv/golang/go
export GOBIN=/Users/taichirain/codeEnv/golang/go/bin
export GOROOT=/usr/local/opt/go/libexec
export $PATH:$GOROOT/bin
source ~/.zshrc
-------------本文结束感谢您的阅读-------------
坚持原创技术分享,您的支持将鼓励我继续创作!