I see the following error when executing npm install -g serverless via buildspec.yml from AWS Codebuild
[email protected] postinstall /usr/local/lib/node_modules/serverless/node_modules/storage-engine node ./compatibility/detect.js
Error: EACCES: permission denied, open '/usr/local/lib/node_modules/serverless/node_modules/storage-engine/lib/compatibility/index.js'
Run “npm config get prefix” in your terminal. This will give the path of global node_modules: For ex: /usr/local. Change the user permissions for this folder by using following command: sudo chown -R <user_id> /usr/local/
If your npm is broken: On Mac or Linux, reinstall npm. Windows: If you're on Windows and you have a broken installation, the easiest thing to do is to reinstall node from the official installer (see this note about installing the latest stable version).
always use sudo -i or sudo -H when running npm install to install global packages. When you use npm , it downloads packages to your user home directory. When you run as sudo, npm installs files to the same directory, but now they are owned by root.
npx is a very powerful command that's been available in npm starting version 5.2, released in July 2017. If you don't want to install npm, you can install npx as a standalone package. npx lets you run code built with Node. js and published through the npm registry.
For instance, running the following command ‘ npm install -g expo-cli ’ returns you with — npm ERR! Error: EACCES: permission denied… … …. npm ERR! The operation was rejected by your operating system. npm ERR! It is likely you do not have the permissions to access this file as the current user npm ERR!
If you see an EACCES error when you try to install a package globally, you can either: Reinstall npm with a node version manager (recommended), This is the best way to avoid permissions issues.
This is the best way to avoid permissions issues. To reinstall 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 Node.js before installing a node version manager. Note: This section does not apply to Microsoft Windows.
Used yarn instead of npm.
yarn global add serverless
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With