ubuntu 16.04
Hyperledger Fabric 1.4.4
nodejs 8.x 当时具体是8点几的版本忘记了
npm版本是安装nodejs时附带安装的,具体版本号忘记了
我在运行官方提供的范例fabcar时,遇到以下问题
运行~/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/fabcar$ ./startFabric.sh,启动网络后。
根据官方文档的说明进入go/src/github.com/hyperledger/fabric/scripts/fabric-samples/fabcar/javascript目录中
安装js脚本运行所需的脚本
sudo npm install
npm install 执行之后就会提示各种各样的error.
运行~/go/src/github.com/hyperledger/fabric/scripts/fabric-samples/fabcar/javascript目录下的enrollAdmin.js等js文件,出现如下报错
报错的主要内容是:Cannot find module 'fabric-ca-client'
意思就是找不到所需的这个模组,这个问题不解决,以后还有各种各样的模组安装不了。
尝试了各种各样的解决方法后均无效,一拍脑壳,这要不然看一下官方文档试试
果然在官方文档中找到了问题所在。
官方文档原话是这么说的:If you will be developing applications for Hyperledger Fabric leveraging the Hyperledger Fabric SDK for Node.js, version 8 is supported from 8.9.4 and higher. Node.js version 10 is supported from 10.15.3 and higher.
大概意思是若使用node.js 8.x,则版本须高于8.9.4。若使用node.js10.x,则版本须高于10.15.3
于是,我选择安装10.x版本的node.js试试。
1. 卸载原来的node和npm
#apt-get 卸载
sudo apt-get remove --purge npm
sudo apt-get remove --purge nodejs
sudo apt-get remove --purge nodejs-legacy
sudo apt-get autoremove
#手动删除 npm 相关目录
rm -r /usr/local/bin/npm
rm -r /usr/local/lib/node-moudels
find / -name npm
rm -r /tmp/npm*
上面有些删除的目录我在删除的时候,发现根本没有~~~,如果提示权限不足,就加上sudo
2. 安装node.js 10.x
curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash -
sudo apt-get install nodejs
安装node.js会附带安装npm
查看是否安装成功
node -v
npm -v
修改npm源为国内镜像,这里使用的是阿里镜像
npm config set registry https://registry.npm.taobao.org
用以下语句验证是否设置成功
npm config get registry
至此,问题解决。
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。