Error installing adonisJS

Asked

Viewed 608 times

0

Hello I’m trying to install Adonis but it’s giving error (I’ve checked with sudo npm i -g @adonisjs/cli):

gyp ERR! configure error 
gyp ERR! stack Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/@adonisjs/cli/node_modules/fsevents/build'
gyp ERR! System Darwin 18.5.0
gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "configure" "--fallback-to-build" "--module=/usr/local/lib/node_modules/@adonisjs/cli/node_modules/fsevents/lib/binding/Release/node-v72-darwin-x64/fse.node" "--module_name=fse" "--module_path=/usr/local/lib/node_modules/@adonisjs/cli/node_modules/fsevents/lib/binding/Release/node-v72-darwin-x64" "--napi_version=4" "--node_abi_napi=napi" "--napi_build_version=0" "--node_napi_label=node-v72"
gyp ERR! cwd /usr/local/lib/node_modules/@adonisjs/cli/node_modules/fsevents
gyp ERR! node -v v12.2.0
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok 
node-pre-gyp ERR! build error 
node-pre-gyp ERR! stack Error: Failed to execute '/usr/local/bin/node /usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build --module=/usr/local/lib/node_modules/@adonisjs/cli/node_modules/fsevents/lib/binding/Release/node-v72-darwin-x64/fse.node --module_name=fse --module_path=/usr/local/lib/node_modules/@adonisjs/cli/node_modules/fsevents/lib/binding/Release/node-v72-darwin-x64 --napi_version=4 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v72' (1)
node-pre-gyp ERR! stack     at ChildProcess.<anonymous> (/usr/local/lib/node_modules/@adonisjs/cli/node_modules/fsevents/node_modules/node-pre-gyp/lib/util/compile.js:83:29)
node-pre-gyp ERR! stack     at ChildProcess.emit (events.js:196:13)
node-pre-gyp ERR! stack     at maybeClose (internal/child_process.js:1011:16)
node-pre-gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:268:5)
node-pre-gyp ERR! System Darwin 18.5.0
node-pre-gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/@adonisjs/cli/node_modules/fsevents/node_modules/node-pre-gyp/bin/node-pre-gyp" "install" "--fallback-to-build"
node-pre-gyp ERR! cwd /usr/local/lib/node_modules/@adonisjs/cli/node_modules/fsevents
node-pre-gyp ERR! node -v v12.2.0
node-pre-gyp ERR! node-pre-gyp -v v0.12.0
node-pre-gyp ERR! not ok 
Failed to execute '/usr/local/bin/node /usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build --module=/usr/local/lib/node_modules/@adonisjs/cli/node_modules/fsevents/lib/binding/Release/node-v72-darwin-x64/fse.node --module_name=fse --module_path=/usr/local/lib/node_modules/@adonisjs/cli/node_modules/fsevents/lib/binding/Release/node-v72-darwin-x64 --napi_version=4 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v72' (1)
  • What is your operating system?

2 answers

2


Your problem is in second line, where it says the following:

gyp ERR! stack Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/@adonisjs/cli/node_modules/fsevents/build'

Since you did not inform your operating system, I will show you how to resolve the permission problem in a general way...

If you notice a mistake of the type EACCES when trying to install a package globally, you can do the following:

  • 1) Reinstall the npm with a node version manager (recommended),
  • 2) Manually change the default directory of npm

Reinstall npm with a node version manager

This is the best way to avoid permissions problems. To reinstall the npm with a node version manager, follow the steps in "Downloading and installing Node.js and npm ". You do not need to remove your current version of npm or of Node.js before installing a node version manager.

Manually change default directory of npm

NOTE: This section does not apply to Microsoft Windows.

To minimize the chance of permission errors, you can configure the npm to use a different directory. In this example, you will create and use the hidden directory in your home directory. Come on?

  • 1) Back up your computer.

  • 2) On the command line, in your home directory, create a directory for global installations: mkdir ~/.npm-global

  • 3) Configure npm to use the new directory path: npm config set prefix '~/.npm-global'

  • 4) In your preferred text editor, open or create a ~/.profilearquivo and add this line: export PATH=~/.npm-global/bin:$PATH

  • 5) On the command line, update your system variables: source ~/.profile

  • 6) To test your new configuration, install a package globally without using sudo: npm install -g jshint

OBS: Instead of steps 2-4, you can use the variable ENV corresponding (for example, if you do not want to modify ~/.profile): NPM_CONFIG_PREFIX=~/.npm-global

Another alternative is to use the NPX (an alternative to run global commands)

If you are using the npm version 5.2 or higher, you may consider the npx as an alternative way to execute global commands, especially if you only need a command occasionally. For more information, see this npx article.

OFFICIAL SOURCE: NPMJS DOCUMENTATION

1

I managed to resolve with the following command.

sudo npm install -g @adonisjs/cli --unsafe-perm=true --allow-root

Browser other questions tagged

You are not signed in. Login or sign up in order to post.