所以我一直在处理一个非常奇怪的问题,这个问题似乎是无中生有的。我的truffle编译、测试和迁移命令实际上什么也不做。然而,我的其他命令,如开发,网络,控制台等工作正常。当我在控制台中输入truffle migrate时,就会发生这种情况:Nothing happens and the the terminal line just goes to a new line
这就是当我运行truffle develop时发生的事情:Works as expected
我用一个开箱即用的毛毛雨应用程序也做了同样的事情。它的配置文件如下所示:
const path = require("path");
module.exports = {
// See <http://truffleframework.com/docs/advanced/configuration>
// to customize your Truffle configuration!
contracts_build_directory: path.join(__dirname, "app/src/contracts"),
solc: {
optimizer: {
enabled: true,
runs: 200
}
},
networks: {
development: {
host: "LOCALHOST",
port: 8545,
network_id: "5777", // Match any network id
}
}};迁移文件如下所示:
const SimpleStorage = artifacts.require("SimpleStorage");
const TutorialToken = artifacts.require("TutorialToken");
const ComplexStorage = artifacts.require("ComplexStorage");
module.exports = function(deployer) {
deployer.deploy(SimpleStorage);
deployer.deploy(TutorialToken);
deployer.deploy(ComplexStorage);
};一切看起来都很正常,我似乎不知道问题出在哪里。以前可以工作的应用程序,现在似乎不能运行松露编译、迁移或测试命令。
所以我最初认为这可能是我的npm包有问题,或者可能需要一个新的更新。所以我卸载并重新安装了truffle@latest。我开始注意到,当我下载某些包时,有时会收到一个特定的错误:
/Users/aditya/.nvm/versions/node/v11.10.0/bin/truffle ->
/Users/aditya/.nvm/versions/node/v11.10.0/lib/node_modules/truffle/build/cli.bundled.js
> keccak@1.4.0 install /Users/aditya/.nvm/versions/node/v11.10.0/lib/node_modules/truffle/node_modules/keccak
> npm run rebuild || echo "Keccak bindings compilation fail. Pure JS implementation will be used."
> keccak@1.4.0 rebuild /Users/aditya/.nvm/versions/node/v11.10.0/lib/node_modules/truffle/node_modules/keccak
> node-gyp rebuild
gyp ERR! configure error
gyp ERR! stack Error: EACCES: permission denied, mkdir '/Users/aditya/.nvm/versions/node/v11.10.0/lib/node_modules/truffle/node_modules/keccak/build'
gyp ERR! System Darwin 18.2.0
gyp ERR! command "/Users/aditya/.nvm/versions/node/v11.10.0/bin/node" "/Users/aditya/.nvm/versions/node/v11.10.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /Users/aditya/.nvm/versions/node/v11.10.0/lib/node_modules/truffle/node_modules/keccak
gyp ERR! node -v v11.10.0
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! keccak@1.4.0 rebuild: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the keccak@1.4.0 rebuild script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
Keccak bindings compilation fail. Pure JS implementation will be used.
+ truffle@5.0.5
added 91 packages from 305 contributors in 7.797s在安装特定的软件包时,这个node-gyp错误会多次出现。因此,我通过卸载并重新安装npm,对我的npm进行了彻底的改造。这并没有改变什么,并且这个错误仍然不断地出现。我不确定此错误是否与Truffle命令问题有关。
发布于 2019-03-01 04:54:46
也有同样的问题,结果是权限问题。
sudo truffle migrate作品
发布于 2020-05-30 12:15:24
我知道这是迟来的回答,但我是为新通勤者发布的,这里的问题可能与目录的所有权有关,因此为了最大限度地减少权限错误的机会,您可以将npm配置为使用不同的目录。
在命令行上的主目录中,为全局安装创建一个目录:
mkdir ~/.npm-global将npm配置为使用新目录路径:
npm config set prefix '~/.npm-global'添加下面这行:
export PATH=~/.npm-global/bin:$PATH在命令行上,更新系统变量:
source ~/.profile要测试新配置,请在不使用sudo的情况下全局安装一个包:
npm install -g node-gyphttps://stackoverflow.com/questions/54875087
复制相似问题