Forums

Error: EACCES: permission denied, access '/usr/lib/node_modules'

Hi I am trying to set up a Django application. At this point, when I run "python manage.py collectstatic" it turned out I needed uglify, so I went back, installed NPM and then tried the following command - 'npm -g install uglify' because I am trying to use the UglifyCompressor. However this fails with the following stacktrace:

I apologize for the long stacktrace. I see that this is a "Permission denied' problem. I could look into that debug file under ./npm/logs What do you think is going on here? Thanks for all the help in advance.

(Env1) 16:26 ~/DonorTilesProject $ npm -g install uglify npm WARN deprecated coffee-script@1.3.3: CoffeeScript on NPM has moved to "coffeescript" (no hyphen) npm WARN deprecated minimatch@0.2.14: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue npm WARN deprecated minimatch@0.3.0: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue WARN deprecated graceful-fs@1.2.3: please upgrade to graceful-fs 4 for compatibility with current and future versions of Node.js npm WARN checkPermissions Missing write access to /usr/lib/node_modules /usr/lib └─┬ uglify@0.1.5 ├── commander@3.0.1 ├─┬ grunt@0.4.5 │ ├── async@0.1.22 │ ├── coffee-script@1.3.3 │ ├── colors@0.6.2 │ ├── dateformat@1.0.2-1.2.3 │ ├── eventemitter2@0.4.14 │ ├── exit@0.1.2 │ ├─┬ findup-sync@0.1.3 │ │ ├─┬ glob@3.2.11 │ │ │ ├── inherits@2.0.4 │ │ │ └── minimatch@0.3.0 │ │ └── lodash@2.4.2 │ ├── getobject@0.1.0 │ ├─┬ glob@3.1.21 │ │ ├── graceful-fs@1.2.3 │ │ └── inherits@1.0.2 │ ├─┬ grunt-legacy-log@0.1.3 │ │ ├─┬ grunt-legacy-log-utils@0.1.1 │ │ │ └── lodash@2.4.2 │ │ └── lodash@2.4.2 │ ├─┬ grunt-legacy-util@0.2.0 │ │ └── underscore.string@2.2.1 │ ├── hooker@0.2.3 │ ├── iconv-lite@0.2.11 │ ├─┬ js-yaml@2.0.5 │ │ ├─┬ argparse@0.1.16 │ │ │ ├── underscore@1.7.0 │ │ │ └── underscore.string@2.4.0 │ │ └── esprima@1.0.4 │ ├── lodash@0.9.2 │ ├─┬ minimatch@0.2.14 │ │ ├── lru-cache@2.7.3 │ │ └── sigmund@1.0.1 │ ├─┬ nopt@1.0.10 │ │ └── abbrev@1.1.1 │ ├── rimraf@2.2.8 │ ├── underscore.string@2.2.1 │ └── which@1.0.9 ├── grunt-contrib-clean@0.5.0 ├── grunt-contrib-concat@0.3.0 ├── grunt-contrib-copy@0.5.0 ├─┬ grunt-contrib-cssmin@0.6.1 │ ├─┬ clean-css@1.0.12 │ │ └─┬ commander@1.3.2 │ │ └── keypress@0.1.0 │ └─┬ grunt-lib-contrib@0.6.1 │ └── zlib-browserify@0.0.1 ├─┬ grunt-contrib-uglify@0.2.4 │ └─┬ uglify-js@2.4.24 │ ├── async@0.2.10 │ ├─┬ source-map@0.1.34 │ │ └── amdefine@1.0.1 │ ├── uglify-to-browserify@1.0.2 │ └─┬ yargs@3.5.4 │ ├── camelcase@1.2.1 │ ├── decamelize@1.2.0 │ ├── window-size@0.1.0 │ └── wordwrap@0.0.2 ├── grunt-css-url-replace@0.2.7 ├── underscore@1.4.4 └── underscore.string@2.3.3

npm ERR! Linux 4.4.0-1087-aws npm ERR! argv "node" "/usr/bin/npm" "-g" "install" "uglify" npm ERR! node v8.11.4 npm ERR! npm v4.3.0 npm ERR! path /usr/lib/node_modules npm ERR! code EACCES npm ERR! errno -13 npm ERR! syscall access

npm ERR! Error: EACCES: permission denied, access '/usr/lib/node_modules' npm ERR! { Error: EACCES: permission denied, access '/usr/lib/node_modules' npm ERR! errno: -13, npm ERR! code: 'EACCES', npm ERR! syscall: 'access', npm ERR! path: '/usr/lib/node_modules' } npm ERR! npm ERR! Please try running this command again as root/Administrator.

npm ERR! Please include the following file with any support request: npm ERR! /home/drivinginstructor/.npm/_logs/2019-09-14T16_27_07_527Z-debug.log

npm install -g will try to install packages for all users on the system. Instead, just use npm install to install for your own directory. I'd also recommend using nvm to get a good recent version of Node -- see this help page for details.

That worked. Ah, I did not know about nvm. Thanks so much