Error: npm ERR! write after end

Clément Jolliet picture Clément Jolliet · Mar 7, 2018 · Viewed 46.6k times · Source

I am having issues installing Cordova and Ionic. At first I couldn't because of what seems to be a corrupted installation, that led me to uninstall NodeJS - Cordova - Ionic.

Now, I've reinstalled NodeJS, without issues but when it comes to the famous line :
npm install -g cordova ionic, I've got this error :
npm ERR! write after end then everytime I try to install cordova ionic, I've got the same error for a different package ...
Here are errors I get :

C:\Windows\System32>npm install -g cordova ionic
npm ERR! write after end    
npm ERR! A complete log of this run can be found in:
npm ERR!     d:\Profiles\cjolliet\AppData\Roaming\npm-cache\_logs\2018-03-07T09_31_22_439Z-debug.log    
C:\Windows\System32>npm install -g cordova ionic
npm ERR! code ETARGET
npm ERR! notarget No matching version found for ansi-styles@^3.2.1
npm ERR! notarget In most cases you or one of your dependencies are requesting
npm ERR! notarget a package version that doesn't exist.
npm ERR! notarget
npm ERR! notarget It was specified as a dependency of 'chalk'
npm ERR! notarget    
npm ERR! A complete log of this run can be found in:
npm ERR!     d:\Profiles\cjolliet\AppData\Roaming\npm-cache\_logs\2018-03-07T09_40_04_399Z-debug.log    
C:\Windows\System32>
C:\Windows\System32>npm install -g cordova ionic
npm ERR! code ETARGET
npm ERR! notarget No matching version found for supports-color@^5.3.0
npm ERR! notarget In most cases you or one of your dependencies are requesting
npm ERR! notarget a package version that doesn't exist.
npm ERR! notarget
npm ERR! notarget It was specified as a dependency of 'chalk'
npm ERR! notarget    
npm ERR! A complete log of this run can be found in:
npm ERR!     d:\Profiles\cjolliet\AppData\Roaming\npm-cache\_logs\2018-03-07T09_44_05_319Z-debug.log

If any of you can help me, it would be very appreciate ;-) Have a nice day...

EDIT 1 : after installing some packages and trying again, I've got this now :

npm install -g cordova ionic
npm WARN tar ENOENT: no such file or directory, open 'd:\Profiles\cjolliet\AppData\Roaming\npm\node_modules\.staging\path-is-absolute-86a430cb\package.json'
npm WARN tar ENOENT: no such file or directory, open 'd:\Profiles\cjolliet\AppData\Roaming\npm\node_modules\.staging\parseurl-f42ab09d\package.json'
npm WARN tar ENOENT: no such file or directory, open 'd:\Profiles\cjolliet\AppData\Roaming\npm\node_modules\.staging\path-is-absolute-86a430cb\index.js'
npm WARN tar ENOENT: no such file or directory, open 'd:\Profiles\cjolliet\AppData\Roaming\npm\node_modules\.staging\opn-07c4c2dd\package.json'
npm WARN tar ENOENT: no such file or directory, open 'd:\Profiles\cjolliet\AppData\Roaming\npm\node_modules\.staging\os-tmpdir-c1eaefc0\package.json'
npm WARN tar ENOENT: no such file or directory, open 'd:\Profiles\cjolliet\AppData\Roaming\npm\node_modules\.staging\parse-glob-106d32b7\package.json'
npm WARN tar ENOENT: no such file or directory, open 'd:\Profiles\cjolliet\AppData\Roaming\npm\node_modules\.staging\parseurl-f42ab09d\README.md'
npm WARN tar ENOENT: no such file or directory, open 'd:\Profiles\cjolliet\AppData\Roaming\npm\node_modules\.staging\path-is-absolute-86a430cb\license'
npm WARN tar ENOENT: no such file or directory, open 'd:\Profiles\cjolliet\AppData\Roaming\npm\node_modules\.staging\opn-07c4c2dd\index.js'
npm WARN tar ENOENT: no such file or directory, open 'd:\Profiles\cjolliet\AppData\Roaming\npm\node_modules\.staging\os-tmpdir-c1eaefc0\index.js'
npm WARN tar ENOENT: no such file or directory, open 'd:\Profiles\cjolliet\AppData\Roaming\npm\node_modules\.staging\parse-glob-106d32b7\README.md'
npm WARN tar ENOENT: no such file or directory, open 'd:\Profiles\cjolliet\AppData\Roaming\npm\node_modules\.staging\parseurl-f42ab09d\LICENSE'
npm WARN tar ENOENT: no such file or directory, open 'd:\Profiles\cjolliet\AppData\Roaming\npm\node_modules\.staging\superagent-4d7c9590\lib\agent-base.js'
npm WARN tar ENOENT: no such file or directory, open 'd:\Profiles\cjolliet\AppData\Roaming\npm\node_modules\.staging\path-is-absolute-86a430cb\readme.md'
npm WARN tar ENOENT: no such file or directory, open 'd:\Profiles\cjolliet\AppData\Roaming\npm\node_modules\.staging\os-tmpdir-c1eaefc0\license'
npm WARN tar ENOENT: no such file or directory, open 'd:\Profiles\cjolliet\AppData\Roaming\npm\node_modules\.staging\opn-07c4c2dd\license'
npm WARN tar ENOENT: no such file or directory, open 'd:\Profiles\cjolliet\AppData\Roaming\npm\node_modules\.staging\parse-glob-106d32b7\LICENSE'
npm WARN tar ENOENT: no such file or directory, open 'd:\Profiles\cjolliet\AppData\Roaming\npm\node_modules\.staging\parseurl-f42ab09d\index.js'
npm WARN tar ENOENT: no such file or directory, open 'd:\Profiles\cjolliet\AppData\Roaming\npm\node_modules\.staging\superagent-4d7c9590\lib\client.js'
npm WARN tar ENOENT: no such file or directory, open 'd:\Profiles\cjolliet\AppData\Roaming\npm\node_modules\.staging\opn-07c4c2dd\readme.md'
npm WARN tar ENOENT: no such file or directory, open 'd:\Profiles\cjolliet\AppData\Roaming\npm\node_modules\.staging\os-tmpdir-c1eaefc0\readme.md'
npm WARN tar ENOENT: no such file or directory, open 'd:\Profiles\cjolliet\AppData\Roaming\npm\node_modules\.staging\parse-glob-106d32b7\index.js'
npm WARN tar ENOENT: no such file or directory, open 'd:\Profiles\cjolliet\AppData\Roaming\npm\node_modules\.staging\parseurl-f42ab09d\HISTORY.md'
npm WARN tar ENOENT: no such file or directory, open 'd:\Profiles\cjolliet\AppData\Roaming\npm\node_modules\.staging\opn-07c4c2dd\xdg-open'
npm WARN tar ENOENT: no such file or directory, open 'd:\Profiles\cjolliet\AppData\Roaming\npm\node_modules\.staging\inquirer-b71d51ab\lib\utils\events.js'
npm WARN tar ENOENT: no such file or directory, open 'd:\Profiles\cjolliet\AppData\Roaming\npm\node_modules\.staging\inquirer-b71d51ab\lib\utils\paginator.js'
npm WARN tar ENOENT: no such file or directory, open 'd:\Profiles\cjolliet\AppData\Roaming\npm\node_modules\.staging\inquirer-b71d51ab\lib\utils\readline.js'
npm WARN tar ENOENT: no such file or directory, open 'd:\Profiles\cjolliet\AppData\Roaming\npm\node_modules\.staging\inquirer-b71d51ab\lib\utils\screen-manager.js'
npm WARN tar ENOENT: no such file or directory, open 'd:\Profiles\cjolliet\AppData\Roaming\npm\node_modules\.staging\readdirp-34d428ea\test\bed\root_dir2\root_dir2_file1.ext1'
npm WARN tar ENOENT: no such file or directory, open 'd:\Profiles\cjolliet\AppData\Roaming\npm\node_modules\.staging\inquirer-b71d51ab\lib\utils\utils.js'
npm WARN tar ENOENT: no such file or directory, open 'd:\Profiles\cjolliet\AppData\Roaming\npm\node_modules\.staging\readdirp-34d428ea\test\bed\root_dir2\root_dir2_file2.ext2'
npm WARN tar ENOENT: no such file or directory, lstat 'd:\Profiles\cjolliet\AppData\Roaming\npm\node_modules\.staging\cordova-lib-a64e9936\src\cordova\metadata'
npm WARN tar ENOENT: no such file or directory, open 'd:\Profiles\cjolliet\AppData\Roaming\npm\node_modules\.staging\qs-095a6ca4\lib\formats.js'
npm WARN tar ENOENT: no such file or directory, open 'd:\Profiles\cjolliet\AppData\Roaming\npm\node_modules\.staging\qs-095a6ca4\lib\index.js'
npm WARN tar ENOENT: no such file or directory, open 'd:\Profiles\cjolliet\AppData\Roaming\npm\node_modules\.staging\qs-095a6ca4\lib\parse.js'
npm WARN tar ENOENT: no such file or directory, open 'd:\Profiles\cjolliet\AppData\Roaming\npm\node_modules\.staging\qs-095a6ca4\lib\stringify.js'
npm WARN tar ENOENT: no such file or directory, open 'd:\Profiles\cjolliet\AppData\Roaming\npm\node_modules\.staging\qs-095a6ca4\lib\utils.js'
npm WARN tar ENOENT: no such file or directory, lstat 'd:\Profiles\cjolliet\AppData\Roaming\npm\node_modules\.staging\cordova-app-hello-world-60bb7e30\template_src\res\icon\blackberry10'
npm WARN tar ENOENT: no such file or directory, open 'd:\Profiles\cjolliet\AppData\Roaming\npm\node_modules\.staging\tiny-lr-cf15ff1c\src\client.js'
npm WARN tar ENOENT: no such file or directory, open 'd:\Profiles\cjolliet\AppData\Roaming\npm\node_modules\.staging\tiny-lr-cf15ff1c\src\index.js'
npm WARN tar ENOENT: no such file or directory, open 'd:\Profiles\cjolliet\AppData\Roaming\npm\node_modules\.staging\tiny-lr-cf15ff1c\src\server.js'
npm ERR! code EINTEGRITY
npm ERR! Verification failed while extracting readable-stream@^2.0.5:
npm ERR! sha512-vuYxeWYM+fde14+rajzqgeohAI7YoJcHE7kXDAc4Nk0EbuKnJfqtY9YtRkLo/tqkuF7MsBQRhPnPeyjYITp3ZQ== integrity checksum failed when using sha512: wanted sha512-vuYxeWYM+fde14+rajzqgeohAI7YoJcHE7kXDAc4Nk0EbuKnJfqtY9YtRkLo/tqkuF7MsBQRhPnPeyjYITp3ZQ== but got sha512-tK0yDhrkygt/knjowCUiWP9YdV7c5R+8cR0r/kt9ZhBU906Fs6RpQJCEilamRJj1Nx2rWI6LkW9gKqjTkshhEw==. (25689 bytes)

Answer

Melchia picture Melchia · Mar 7, 2018

Try installing latest npm version this happens a lot with ionic.

npm install -g npm@latest
npm cache verify
npm i 

If this doesn't work I advise you to switch to yarn. It's faster & easier to use. This is the link to download YARN. After installing just run this command yarn global add cordova ionic

Ionic CLI uses npm by default. So go to your project & run $ yarn install.

If you want Ionic to use yarn by default run this: $ ionic config set -g yarn true