npm Community Forum (Archive)

The npm community forum has been discontinued.

To discuss usage of npm, visit the GitHub Support Community.

What is the recommended way of installing for Windows Subsystem for Linux (WSL)?

I was originally working with npm via its Windows installer, and running it in PowerShell. But using that to install https://github.com/aws-amplify/amplify-cli didn’t work well, so I setup Bash/Ubuntu/WindowsSubsystemForLinux, uninstalled npm for Windows, and tried sudo apt-get install node and the same for npm. After that, npm install in my project folders usually breaks due to ENOENT or an untar failure.

I googled for the recommended way of installing npm for WSL and found suggestions like https://www.youtube.com/watch?v=hiWWXCZbY6A It involves replacing the npm installed via sudo apt-get with one via ‘n’.

Would you provide a guide about the recommended way of installing for WSL.


This trace shows that I’ve tried to install npm (on WSL) in the recommended ways. But I still get the following whenever I try “npm install”:

npm ERR! tar.unpack untar error /home/vada/.npm/rxjs/6.5.2/package.tgz
npm ERR! tar.unpack untar error /home/vada/.npm/moment/2.24.0/package.tgz
npm ERR! tar.unpack untar error /home/vada/.npm/core-js/1.2.7/package.tgz
npm ERR! tar.unpack untar error /home/vada/.npm/caniuse-lite/1.0.30000974/package.tgz
npm ERR! tar.unpack untar error /home/vada/.npm/core-js/3.0.1/package.tgz

If some entries in my package.json below are obsolete, how do I auto-update them?

{
  "name": "modality-web-view",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "aws-amplify": "^1.1.28",
    "glamor": "^2.20.40",
    "moment": "^2.24.0",
    "query-string": "^6.5.0",
    "react": "^16.8.6",
    "react-bootstrap": "^1.0.0-beta.8",
    "react-datepicker": "^2.5.0",
    "react-dom": "^16.8.6",
    "react-files": "^2.4.8",
    "react-loading-overlay": "^1.0.1",
    "react-router-dom": "^4.3.1",
    "react-scripts": "^3.0.1",
    "ts-react-json-table": "^0.1.1",
    "typescript": "^3.4.5"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  },
  "eslintConfig": {
    "extends": "react-app"
  },
  "browserslist": [
    ">0.2%",
    "not dead",
    "not ie <= 11",
    "not op_mini all"
  ]
}

Following Installing/upgrading npm I tried:

$ sudo npm i -g npm@latest
[sudo] password for vada:
/usr/local/lib
└── (empty)

npm ERR! Linux 4.4.0-17134-Microsoft
npm ERR! argv "/usr/local/bin/node" "/usr/bin/npm" "i" "-g" "npm@latest"
npm ERR! node v10.16.0
npm ERR! npm  v3.10.10
npm ERR! path /usr/local/lib/node_modules/.staging/p-locate-f1fa4a30
npm ERR! code ENOENT
npm ERR! errno -2
npm ERR! syscall rename

npm ERR! enoent ENOENT: no such file or directory, rename '/usr/local/lib/node_modules/.staging/p-locate-f1fa4a30' -> '/usr/local/lib/node_modules/npm/node_modules/p-locate'
npm ERR! enoent ENOENT: no such file or directory, rename '/usr/local/lib/node_modules/.staging/p-locate-f1fa4a30' -> '/usr/local/lib/node_modules/npm/node_modules/p-locate'
npm ERR! enoent This is most likely not a problem with npm itself
npm ERR! enoent and is related to npm not being able to find a file.
npm ERR! enoent

npm ERR! Please include the following file with any support request:
npm ERR!     /mnt/e/[deleted]/webview/npm-debug.log
npm ERR! code 1


$ curl http://npmjs.org/install.sh | sh
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0

$ npm --version
3.10.10

$ node --version
v10.16.0

Removed node_modules/ in my project folder

webview$ npm install
npm WARN deprecated core-js@1.2.7: core-js@<2.6.8 is no longer maintained. Please, upgrade to core-js@3 or at least to actual version of core-js@2.
npm WARN deprecated left-pad@1.3.0: use String.prototype.padStart()
npm WARN deprecated flatten@1.0.2: I wrote this module a very long time ago; you should use something else.
npm ERR! tar.unpack untar error /home/vada/.npm/rxjs/6.5.2/package.tgz
npm ERR! tar.unpack untar error /home/vada/.npm/moment/2.24.0/package.tgz
npm ERR! tar.unpack untar error /home/vada/.npm/core-js/1.2.7/package.tgz
npm ERR! tar.unpack untar error /home/vada/.npm/caniuse-lite/1.0.30000974/package.tgz
npm ERR! tar.unpack untar error /home/vada/.npm/core-js/3.0.1/package.tgz
modality-web-view@0.1.0 /mnt/e/[deleted]/webview
├── @babel/code-frame@7.0.0  extraneous
├── @babel/core@7.4.3  extraneous
├── @babel/helper-plugin-utils@7.0.0  extraneous
├── @babel/plugin-syntax-object-rest-spread@7.2.0  extraneous
├── @cnakazawa/watch@1.0.3  extraneous
├── @jest/console@24.7.1  extraneous
├── @jest/environment@24.8.0  extraneous
├── @jest/test-sequencer@24.8.0  extraneous
├── @webassemblyjs/ast@1.8.5  extraneous
├─┬ aws-amplify@1.1.28
│ ├─┬ @aws-amplify/analytics@1.2.16
│ │ └── uuid@3.3.2
│ ├─┬ @aws-amplify/api@1.0.35
│ │ ├── @types/zen-observable@0.5.4
│ │ ├─┬ axios@0.17.1
│ │ │ ├─┬ follow-redirects@1.7.0
│ │ │ │ └─┬ debug@3.2.6
│ │ │ │   └── ms@2.1.2
│ │ │ └── is-buffer@1.1.6
│ │ ├─┬ graphql@0.13.0
│ │ │ └── iterall@1.1.4
│ │ └── zen-observable@0.8.14
│ ├─┬ @aws-amplify/auth@1.2.24
│ │ ├─┬ amazon-cognito-identity-js@3.0.12
│ │ │ ├─┬ buffer@4.9.1
│ │ │ │ ├── base64-js@1.3.0
│ │ │ │ └── isarray@1.0.0
│ │ │ └── js-cookie@2.2.0
│ │ └── crypto-js@3.1.9-1
│ ├── @aws-amplify/cache@1.0.27
│ ├─┬ @aws-amplify/core@1.0.27
│ │ ├─┬ aws-sdk@2.329.0
│ │ │ ├── events@1.1.1
│ │ │ ├── ieee754@1.1.8
│ │ │ ├── jmespath@0.15.0
│ │ │ ├── querystring@0.2.0
│ │ │ ├── sax@1.2.1
│ │ │ ├── url@0.10.3
│ │ │ ├── uuid@3.1.0
│ │ │ └─┬ xml2js@0.4.19
│ │ │   └── xmlbuilder@9.0.7
│ │ └─┬ url@0.11.0
│ │   └── punycode@1.3.2
│ ├── @aws-amplify/interactions@1.0.30
│ ├── @aws-amplify/pubsub@1.0.28
│ ├── @aws-amplify/storage@1.0.30
│ ├── @aws-amplify/ui@1.0.19
│ └── @aws-amplify/xr@0.1.17
├─┬ glamor@2.20.40
│ ├─┬ inline-style-prefixer@3.0.8
│ │ ├── bowser@1.9.4
│ │ └─┬ css-in-js-utils@2.0.1
│ │   ├── hyphenate-style-name@1.0.3
│ │   └── isobject@3.0.1
│ ├── object-assign@4.1.1
│ ├─┬ prop-types@15.7.2
│ │ └── react-is@16.8.6
│ └── through@2.3.8
├─┬ query-string@6.7.0
│ ├── decode-uri-component@0.2.0
│ ├── split-on-first@1.1.0
│ └── strict-uri-encode@2.0.0
├─┬ react@16.8.6
│ ├─┬ loose-envify@1.4.0
│ │ └── js-tokens@4.0.0
│ └── scheduler@0.13.6
├─┬ react-datepicker@2.7.0
│ ├── classnames@2.2.6
│ ├── date-fns@2.0.0-alpha.34
│ └── react-onclickoutside@6.8.0
├── react-dom@16.8.6
├── react-files@2.4.8
├─┬ react-loading-overlay@1.0.1
│ ├─┬ emotion@10.0.9
│ │ ├─┬ babel-plugin-emotion@10.0.13
│ │ │ ├─┬ @babel/helper-module-imports@7.0.0
│ │ │ │ └─┬ @babel/types@7.4.4
│ │ │ │   ├── esutils@2.0.2
│ │ │ │   ├── lodash@4.17.11
│ │ │ │   └── to-fast-properties@2.0.0
│ │ │ ├── @emotion/hash@0.7.1
│ │ │ ├── @emotion/memoize@0.7.1
│ │ │ ├─┬ @emotion/serialize@0.11.7
│ │ │ │ ├── @emotion/unitless@0.7.3
│ │ │ │ └── csstype@2.6.5
│ │ │ ├─┬ babel-plugin-macros@2.6.1
│ │ │ │ ├─┬ cosmiconfig@5.2.1
│ │ │ │ │ ├─┬ import-fresh@2.0.0
│ │ │ │ │ │ ├─┬ caller-path@2.0.0
│ │ │ │ │ │ │ └─┬ caller-callsite@2.0.0
│ │ │ │ │ │ │   └── callsites@2.0.0
│ │ │ │ │ │ └── resolve-from@3.0.0
│ │ │ │ │ ├── is-directory@0.3.1
│ │ │ │ │ ├─┬ js-yaml@3.13.1
│ │ │ │ │ │ ├─┬ argparse@1.0.10
│ │ │ │ │ │ │ └── sprintf-js@1.0.3
│ │ │ │ │ │ └── esprima@4.0.1
│ │ │ │ │ └─┬ parse-json@4.0.0
│ │ │ │ │   ├─┬ error-ex@1.3.2
│ │ │ │ │   │ └── is-arrayish@0.2.1
│ │ │ │ │   └── json-parse-better-errors@1.0.2
│ │ │ │ └─┬ resolve@1.11.0
│ │ │ │   └── path-parse@1.0.6
│ │ │ ├── babel-plugin-syntax-jsx@6.18.0
│ │ │ ├─┬ convert-source-map@1.6.0
│ │ │ │ └── safe-buffer@5.1.2
│ │ │ ├── escape-string-regexp@1.0.5
│ │ │ ├── find-root@1.1.0
│ │ │ └── source-map@0.5.7
│ │ └─┬ create-emotion@10.0.9
│ │   ├─┬ @emotion/cache@10.0.9
│ │   │ ├── @emotion/stylis@0.8.3
│ │   │ └── @emotion/weak-memoize@0.2.2
│ │   ├── @emotion/sheet@0.9.2
│ │   └── @emotion/utils@0.11.1
│ └─┬ react-transition-group@2.9.0
│   ├── dom-helpers@3.4.0
│   └── react-lifecycles-compat@3.0.4
├─┬ react-router-dom@4.3.1
│ ├─┬ history@4.9.0
│ │ ├─┬ @babel/runtime@7.4.5
│ │ │ └── regenerator-runtime@0.13.2
│ │ ├── resolve-pathname@2.2.0
│ │ ├── tiny-invariant@1.0.4
│ │ ├── tiny-warning@1.0.2
│ │ └── value-equal@0.4.0
│ ├── invariant@2.2.4
│ ├─┬ react-router@4.3.1
│ │ ├── hoist-non-react-statics@2.5.5
│ │ └─┬ path-to-regexp@1.7.0
│ │   └── isarray@0.0.1
│ └── warning@4.0.3
├── ts-react-json-table@0.1.2
└── typescript@3.5.2

npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@2.0.6 (node_modules/react-scripts/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.0.6: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.2.7 (node_modules/jest-haste-map/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.9: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.2.7 (node_modules/chokidar/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.9: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: caniuse-lite@1.0.30000974 (node_modules/caniuse-lite):
npm WARN enoent SKIPPING OPTIONAL DEPENDENCY: ENOENT: no such file or directory, utime '/mnt/e/[deleted]/webview/node_modules/.staging/caniuse-lite-81405ece/data/features/stream.js'
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: core-js@3.0.1 (node_modules/react-app-polyfill/node_modules/core-js):
npm WARN enoent SKIPPING OPTIONAL DEPENDENCY: ENOENT: no such file or directory, utime '/mnt/e/[deleted]/webview/node_modules/.staging/core-js-8338bf89/modules/esnext.array.last-index.js'
npm ERR! Linux 4.4.0-17134-Microsoft
npm ERR! argv "/usr/local/bin/node" "/usr/bin/npm" "install"
npm ERR! node v10.16.0
npm ERR! npm  v3.10.10
npm ERR! path /mnt/e/[deleted]/webview/node_modules/.staging/rxjs-6b1c55b8/_esm2015/internal/observable/from.js
npm ERR! code ENOENT
npm ERR! errno -2
npm ERR! syscall utime

npm ERR! enoent ENOENT: no such file or directory, utime '/mnt/e/[deleted]/webview/node_modules/.staging/rxjs-6b1c55b8/_esm2015/internal/observable/from.js'
npm ERR! enoent ENOENT: no such file or directory, utime '/mnt/e/[deleted]/webview/node_modules/.staging/rxjs-6b1c55b8/_esm2015/internal/observable/from.js'
npm ERR! enoent This is most likely not a problem with npm itself
npm ERR! enoent and is related to npm not being able to find a file.
npm ERR! enoent

npm ERR! Please include the following file with any support request:
npm ERR!     /mnt/e/[deleted]/webview/npm-debug.log


I have made some progress. First, I tried everything suggested in https://github.com/npm/npm/issues/5133 but none of these fixed the problem: Running WSL as Admin, using sudo, npm cache clean. However, after all that, when I manually installed each module version that failed untar, it succeeded…with one exception. For the last module, I changed focus to another app for awhile, and when I returned I saw an untar error again. But retrying it while not changing focus allowed it to succeed.

So, I think there could be multiple causes of failure:

The sudo expiration can be extended: https://unix.stackexchange.com/questions/77356/how-long-is-the-password-for-executing-a-command-with-sudo-cached


This is recently enough that I thought to ask if these are problems using WSL or WSL2?


This is recently enough that I thought to ask if these are problems using WSL or WSL2?

I wasn’t sure what you meant about “WSL2”, and google led me to https://github.com/Microsoft/WSL/issues/1728#issuecomment-452751912 which advises:

$ cmd.exe /c “systeminfo” | grep “^OS Version”
OS Version: 10.0.17134 N/A Build 17134

$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 14.04.6 LTS
Release: 14.04
Codename: trusty

It’s still the case that whenever I try “npm install” (in my @aws-amplify/cli project) there’s an ENOENT error ever time, and it’s usually about a different file than previous times.

Here’s some other version info:
$ node --version
v10.16.0

$ npm --version
3.10.10

I’m using only executables installed via ‘sudo apt-get’, not Windows executables.


The WSL I was using runs from C:\Windows\System32\bash.exe This seems to be an outdated WSL. I later installed Ubuntu 18.04 LTS from the Microsoft Store app – the new WSL – and I had no ENOENT errors while installing npm or any modules.