truffle compile error (EACCES: permission denied) on V5 w/ Linux

Created on 22 Aug 2018  ยท  15Comments  ยท  Source: trufflesuite/truffle

  • [x ] I've asked for help in the Truffle Gitter before filing this issue.

Issue

After installing truffle V5 when truffle compile is called the following error message appears:

Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/truffle/node_modules/.cache'

Steps to Reproduce

npm install -g truffle@next

truffle compile

when calling sudo truffle complie one time the error will not appear anymore.

Expected Behavior

call truffle compile and not sudo truffle compile

Actual Results

Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/truffle/node_modules/.cache'

Environment

  • Operating System: Linux
  • Ethereum client: ganache-cli
  • Truffle version (truffle version): v5.0.0-next.9 (core: 4.1.14)
  • node version (node --version): 8.11.3
  • npm version (npm --version): 6.4.0
Next

Most helpful comment

I am curious why this one was closed while not fixed.

All 15 comments

@Bowfish Does this problem go away if you sudo npm install -g truffle? And it goes away if you call sudo on the command once?

No. I installed it as user root.

So generally you probably don't want to be doing sudo npm install -g anyway. It's better to configure NPM to allow user-level global installs.

Here's a guide: https://github.com/sindresorhus/guides/blob/master/npm-global-without-sudo.md

Thanks for the hint.

Sent from ProtonMail, Swiss-based encrypted email.

โ€โ€โ€โ€โ€โ€โ€ Original Message โ€โ€โ€โ€โ€โ€โ€
Am 22. August 2018 7:05 PM schrieb gnidan notifications@github.com:

So generally you probably don't want to be doing sudo npm install -g anyway. It's better to configure NPM to allow user-level global installs.

Here's a guide: https://github.com/sindresorhus/guides/blob/master/npm-global-without-sudo.md

โ€”
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.

@Bowfish Closing for house-keeping but thanks for opening, I'm sure other people will run into this too.

I am curious why this one was closed while not fixed.

@lbthomsen This is a problem with how truffle was installed I believe or your npm installation. See @gnidan's comment above which I think is relevant.

I am curious why this one was closed while not fixed.

I met the same problem. But then I followed the guide in @gnidan's comment and reinstalled the truffle, and I successfully fixed it.

As a last resort, sudo truffle compile should.

Trying to update to Truffle v5.0 and getting this error.
I had to update npm and then install truffle without sudo npm install -g truffle

I just reinstall truffle, global, on a fresh ubuntu system and the behavior is the same.
As a fix, I create manually the following directory: "/usr/lib/node_modules/truffle/node_modules/.cache/truffle" with the command:
sudo mkdir -p /usr/lib/node_modules/truffle/node_modules/.cache/truffle. The -p allows me to create the .cache and its sub directory truffle at once.

IMHO, the installation must care about this directories.
Under these circumstances, this issue cannot be considered closed.

@m0pu This is not a Truffle-specific issue but rather an issue with how npm was installed I believe. You should probably use something like nvm. You can check this out --> https://docs.npmjs.com/resolving-eacces-permissions-errors-when-installing-packages-globally

Everyone including me is still having the same issue, It should not have been closed

It is solved for me
subdirectories in node_modules should have uniform ownership
Basically, I first ran
sudo chown -R <username> <node modules locations>
and then sudo npm install truffle

@ubaid-qureshi npm and truffle should not be installed as sudo. Check this out https://github.com/trufflesuite/truffle/issues/1711#issuecomment-464833806 I had a similiar problem and everything is working just fine after I installed node with nvm as a normal user and not as sudo.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

rstormsf picture rstormsf  ยท  3Comments

maximilianh picture maximilianh  ยท  3Comments

tcurdt picture tcurdt  ยท  3Comments

jleeh picture jleeh  ยท  3Comments

ferittuncer picture ferittuncer  ยท  3Comments