Unable to build with npm in Ubuntu 18.10 in WSL.

Clean install.

(base) balter@spectre:~$ which node
(base) balter@spectre:~$ which yarn
(base) balter@spectre:~$ sudo apt install nodejs yarn -y
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
gyp libc-ares2 libhttp-parser2.8 libjs-async libjs-bowser libjs-events libjs-inherits libjs-is-typedarray libjs-jstimezonedetect libjs-merge libjs-node-uuid libjs-rtcninja
libjs-sdp-transform libjs-sprintf-js libjs-typedarray-to-buffer libssl1.0-dev libuv1-dev nodejs-doc
Use 'sudo apt autoremove' to remove them.
The following NEW packages will be installed:
nodejs yarn
0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded.
Need to get 890 kB/16.7 MB of archives.
After this operation, 81.9 MB of additional disk space will be used.
Get:1 https://dl.yarnpkg.com/debian stable/main amd64 yarn all 1.19.0-1 [890 kB]
Fetched 890 kB in 1s (1693 kB/s)
debconf: delaying package configuration, since apt-utils is not installed
Selecting previously unselected package nodejs.
(Reading database ... 128262 files and directories currently installed.)
Preparing to unpack .../nodejs_10.16.3-1nodesource1_amd64.deb ...
Unpacking nodejs (10.16.3-1nodesource1) ...
Selecting previously unselected package yarn.
Preparing to unpack .../archives/yarn_1.19.0-1_all.deb ...
Unpacking yarn (1.19.0-1) ...
Setting up nodejs (10.16.3-1nodesource1) ...
Setting up yarn (1.19.0-1) ...
Processing triggers for man-db (2.8.4-2) ...
(base) balter@spectre:~$ which node
/usr/bin/node
(base) balter@spectre:~$ which npm
/usr/bin/npm
(base) balter@spectre:~$ which yarn
/usr/bin/yarn
(base) balter@spectre:~$ nodejs -v
v10.16.3
(base) balter@spectre:~$ npm -v
6.9.0
(base) balter@spectre:~$ yarn -v
1.19.0

And yet, all package installations fail, including updating npm:

(base) balter@spectre:~$ npm install npm@latest -g
npm WARN checkPermissions Missing write access to /usr/lib/node_modules/npm/node_modules/agent-base
npm WARN checkPermissions Missing write access to /usr/lib/node_modules/npm/node_modules/agentkeepalive
npm WARN checkPermissions Missing write access to /usr/lib/node_modules/npm/node_modules/block-stream
npm WARN checkPermissions Missing write access to /usr/lib/node_modules/npm/node_modules/bluebird
npm WARN checkPermissions Missing write access to /usr/lib/node_modules/npm/node_modules/cacache/node_modules/chownr
npm WARN checkPermissions Missing write access to /usr/lib/node_modules/npm/node_modules/cacache/node_modules/unique-filename
npm WARN checkPermissions Missing write access to /usr/lib/node_modules/npm/node_modules/cacache/node_modules/yallist
npm WARN checkPermissions Missing write access to /usr/lib/node_modules/npm/node_modules/cacache/node_modules/lru-cache
npm WARN checkPermissions Missing write access to /usr/lib/node_modules/npm/node_modules/chownr
npm WARN checkPermissions Missing write access to /usr/lib/node_modules/npm/node_modules/es6-promise
npm WARN checkPermissions Missing write access to /usr/lib/node_modules/npm/node_modules/fs-minipass
npm WARN checkPermissions Missing write access to /usr/lib/node_modules/npm/node_modules/fstream
npm WARN checkPermissions Missing write access to /usr/lib/node_modules/npm/node_modules/graceful-fs
npm WARN checkPermissions Missing write access to /usr/lib/node_modules/npm/node_modules/cmd-shim
npm WARN checkPermissions Missing write access to /usr/lib/node_modules/npm/node_modules/https-proxy-agent
npm WARN checkPermissions Missing write access to /usr/lib/node_modules/npm/node_modules/inherits
npm WARN checkPermissions Missing write access to /usr/lib/node_modules/npm/node_modules/glob
npm WARN checkPermissions Missing write access to /usr/lib/node_modules/npm/node_modules/libnpmaccess/node_modules/aproba
npm WARN checkPermissions Missing write access to /usr/lib/node_modules/npm/node_modules/libnpmconfig/node_modules/p-try
npm WARN checkPermissions Missing write access to /usr/lib/node_modules/npm/node_modules/libnpmconfig/node_modules/p-limit
npm WARN checkPermissions Missing write access to /usr/lib/node_modules/npm/node_modules/libnpmorg/node_modules/aproba
npm WARN checkPermissions Missing write access to /usr/lib/node_modules/npm/node_modules/libnpmteam/node_modules/aproba
npm WARN checkPermissions Missing write access to /usr/lib/node_modules/npm/node_modules/minizlib
npm WARN checkPermissions Missing write access to /usr/lib/node_modules/npm/node_modules/node-gyp/node_modules/tar
npm WARN checkPermissions Missing write access to /usr/lib/node_modules/npm/node_modules/npm-packlist
npm WARN checkPermissions Missing write access to /usr/lib/node_modules/npm/node_modules/pacote/node_modules/yallist
npm WARN checkPermissions Missing write access to /usr/lib/node_modules/npm/node_modules/pacote/node_modules/lru-cache
npm WARN checkPermissions Missing write access to /usr/lib/node_modules/npm/node_modules/read-cmd-shim
npm WARN checkPermissions Missing write access to /usr/lib/node_modules/npm/node_modules/gentle-fs
npm WARN checkPermissions Missing write access to /usr/lib/node_modules/npm/node_modules/read-package-json
npm WARN checkPermissions Missing write access to /usr/lib/node_modules/npm/node_modules/readdir-scoped-modules
npm WARN checkPermissions Missing write access to /usr/lib/node_modules/npm/node_modules/semver
npm WARN checkPermissions Missing write access to /usr/lib/node_modules/npm/node_modules/sha/node_modules/string_decoder
npm WARN checkPermissions Missing write access to /usr/lib/node_modules/npm/node_modules/sha/node_modules/readable-stream
npm WARN checkPermissions Missing write access to /usr/lib/node_modules/npm/node_modules/smart-buffer
npm WARN checkPermissions Missing write access to /usr/lib/node_modules/npm/node_modules/socks
npm WARN checkPermissions Missing write access to /usr/lib/node_modules/npm/node_modules/socks-proxy-agent
npm WARN checkPermissions Missing write access to /usr/lib/node_modules/npm/node_modules/tar/node_modules/chownr
npm WARN checkPermissions Missing write access to /usr/lib/node_modules/npm/node_modules/tar
npm WARN checkPermissions Missing write access to /usr/lib/node_modules/npm/node_modules/node-gyp
npm WARN checkPermissions Missing write access to /usr/lib/node_modules/npm/node_modules/npm-lifecycle
npm WARN checkPermissions Missing write access to /usr/lib/node_modules/npm/node_modules/worker-farm
npm WARN checkPermissions Missing write access to /usr/lib/node_modules/npm/node_modules/write-file-atomic
npm WARN checkPermissions Missing write access to /usr/lib/node_modules/npm/node_modules/bin-links
npm WARN checkPermissions Missing write access to /usr/lib/node_modules/npm/node_modules/yallist
npm WARN checkPermissions Missing write access to /usr/lib/node_modules/npm/node_modules/lru-cache
npm WARN checkPermissions Missing write access to /usr/lib/node_modules/npm/node_modules/cacache
npm WARN checkPermissions Missing write access to /usr/lib/node_modules/npm/node_modules/hosted-git-info
npm WARN checkPermissions Missing write access to /usr/lib/node_modules/npm/node_modules/npm-package-arg
npm WARN checkPermissions Missing write access to /usr/lib/node_modules/npm/node_modules/npm-pick-manifest
npm WARN checkPermissions Missing write access to /usr/lib/node_modules/npm/node_modules/make-fetch-happen
npm WARN checkPermissions Missing write access to /usr/lib/node_modules/npm/node_modules/npm-registry-fetch
npm WARN checkPermissions Missing write access to /usr/lib/node_modules/npm/node_modules/libnpmaccess
npm WARN checkPermissions Missing write access to /usr/lib/node_modules/npm/node_modules/libnpmhook
npm WARN checkPermissions Missing write access to /usr/lib/node_modules/npm/node_modules/libnpmorg
npm WARN checkPermissions Missing write access to /usr/lib/node_modules/npm/node_modules/libnpmpublish
npm WARN checkPermissions Missing write access to /usr/lib/node_modules/npm/node_modules/libnpmsearch
npm WARN checkPermissions Missing write access to /usr/lib/node_modules/npm/node_modules/libnpmteam
npm WARN checkPermissions Missing write access to /usr/lib/node_modules/npm/node_modules/npm-profile
npm WARN checkPermissions Missing write access to /usr/lib/node_modules/npm/node_modules/pacote
npm WARN checkPermissions Missing write access to /usr/lib/node_modules/npm/node_modules/call-limit
npm WARN checkPermissions Missing write access to /usr/lib/node_modules/npm/node_modules/libcipm
npm WARN checkPermissions Missing write access to /usr/lib/node_modules/npm/node_modules/libnpm
npm WARN checkPermissions Missing write access to /usr/lib/node_modules/npm/node_modules/query-string
npm WARN checkPermissions Missing write access to /usr/lib/node_modules/npm/node_modules/read-package-tree
npm WARN checkPermissions Missing write access to /usr/lib/node_modules/npm/node_modules/readable-stream
npm WARN checkPermissions Missing write access to /usr/lib/node_modules/npm/node_modules/sha
npm WARN checkPermissions Missing write access to /usr/lib/node_modules/npm
npm WARN checkPermissions Missing write access to /usr/lib/node_modules/npm/node_modules
npm WARN checkPermissions Missing write access to /usr/lib/node_modules/npm/node_modules/cacache/node_modules
npm WARN checkPermissions Missing write access to /usr/lib/node_modules/npm/node_modules/libnpmaccess/node_modules
npm WARN checkPermissions Missing write access to /usr/lib/node_modules/npm/node_modules/libnpmconfig/node_modules
npm WARN checkPermissions Missing write access to /usr/lib/node_modules/npm/node_modules/libnpmorg/node_modules
npm WARN checkPermissions Missing write access to /usr/lib/node_modules/npm/node_modules/libnpmteam/node_modules
npm WARN checkPermissions Missing write access to /usr/lib/node_modules/npm/node_modules/node-gyp/node_modules
npm WARN checkPermissions Missing write access to /usr/lib/node_modules/npm/node_modules/pacote/node_modules
npm WARN checkPermissions Missing write access to /usr/lib/node_modules/npm/node_modules/sha/node_modules
npm WARN checkPermissions Missing write access to /usr/lib/node_modules/npm/node_modules/tar/node_modules
npm WARN checkPermissions Missing write access to /usr/lib/node_modules
npm WARN checkPermissions Missing write access to /usr/lib/node_modules/npm/node_modules/cross-spawn
npm ERR! path /usr/lib/node_modules/npm/node_modules/agent-base
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall access
npm ERR! Error: EACCES: permission denied, access '/usr/lib/node_modules/npm/node_modules/agent-base'
npm ERR!  { [Error: EACCES: permission denied, access '/usr/lib/node_modules/npm/node_modules/agent-base']
npm ERR!   stack:
npm ERR!    'Error: EACCES: permission denied, access \'/usr/lib/node_modules/npm/node_modules/agent-base\'',
npm ERR!   errno: -13,
npm ERR!   code: 'EACCES',
npm ERR!   syscall: 'access',
npm ERR!   path: '/usr/lib/node_modules/npm/node_modules/agent-base' }
npm ERR!
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!
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator (though this is not recommended).

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/balter/.npm/_logs/2019-10-05T22_07_29_817Z-debug.log

Unless you change the install location (prefix) or the ownership or permissions, you need to use sudo with global installs on Linux and Mac:

sudo npm install npm@latest -g

Edit: missed the WSL, but I think same comment applies!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.