解决Truffle搭建项目环境时候出现ExtendableError: Could not find suitable configuration file.

首先,搭建区块链环境需要一个私有链或者公链,这里使用的是Ganache的quickstart 创建一个区块链实例。如下图:红色圈圈里面代表端口,配置truffle-config.js会用到。

在这里插入图片描述

第二步:利用truffle init命令创建一个项目时,一般出现的文件目录如下:

.
├── contracts
│ └── Migrations.sol
├── migrations
│ └── 1_initial_migration.js
├── test
├── truffle-config.js
└── truffle.js

第三步,配置truffle-config.js。添加如下信息,注意记得改port,对应上面的ganache创建的端口即可

module.exports = {
networks: {
development: {
host: “127.0.0.1”, // Localhost (default: none)
port: 7545, // Standard Ethereum port (default: none)
network_id: “*” // Any network (default: none)
}
}
}

这个时候直接运行** truffle migrate**命令,如果出现下图就成功部署了。
在这里插入图片描述
如果出现ExtendableError: Could not find suitable configuration file.

解决办法:要cd进入到truffle-config.js或者truffle.js文件的所在目录下再运行

猜你喜欢

转载自blog.csdn.net/liuzr_/article/details/126096033