npm ERR! asyncWrite is not a function

眉间皱痕 提交于 2019-12-03 04:12:11
Stev

The solution mentioned by DKebler did not work for me either, still got the same error and debug log.

I had also to downgrade.

Command Lines

sudo npm cache clean -f

sudo n 8.11.2

I am guessing it is an incompatibility between npm v5 and node v10. To solve this I downgraded node to v9, upgraded npm to v6, then upgraded node to v10:

n 9.10.1
npm i -g npm
n stable

that's because, when I'm writing this answer, node 10 is not quite stable. So better stick to node 8. for that you can downgrade to 8.11.3 using

sudo n 8.11.3

then you can easily install npm modules.

Reinstalling npm -- mentioned in n installation guide -- worked for me.

$ curl -0 -L https://npmjs.com/install.sh | sudo sh

n was updated in v2.1.12 to address this issue. Previously, the new npm was just being copied over the existing folder. This could cause problems when the layout of the node_modules changed as happened in node 10.

Deleting npm and reinstalling will fix the npm issue. Upgrading n will prevent the issue from happening again when switching versions using n.

https://github.com/tj/n/issues/508#issuecomment-423933394

e.g.

$ rm /usr/local/bin/node
$ rm -rf /usr/local/lib/node_modules/npm
$ n latest
$ npm install -g n
/usr/local/bin/n -> /usr/local/lib/node_modules/n/bin/n
+ n@2.1.12
updated 1 package in 0.466s

It's versions problem. npm 6.1.0node 10.2.*

try n 10.2.1

Solution for windows platform

  1. Uninstall Node
  2. Delete folder from programfiles if exist (C:\Program Files\nodejs)
  3. Delete npm's data folder: C:\Users{Your uername}\AppData\Roaming\nmp

Install node Again(use different installation folder like "C:\Program Files\nodejs-2")

Root cause is node and nvm installed in same installation folder.

Galois.Z
  1. Install an old version node, which can run success.
  2. Update your npm (global).
  3. Install the high version node.

The following is worked in my local environment.

First install and old version node.

sudo n 8.11.3

And then update npm.

sudo npm i -g npm

Now, you update your node, everything work fine.

sudo n 10.12.0

You have to downgrade the node version to latest stable version i.e 8.11.2 because latest version of node is not compatible yet with all npm modules.

Just ran into this error myself when trying to install express via npm. My simple solution was to downgrade node to the stable release. If you have "n", the node version manager, it can be done so with the command:

n stable

Hopefully this helps! I highly recommend "n" if you haven't used it before. It makes life easier :)

Usually, the best way for fix it is:

rm -R /usr/local/lib/node_modules/npm and reinstall Node.js.

My recommendation is install every time Node.js from source code (yes, running make && make install). If you using Debian/Ubuntu, remember first install build-essential

$ sudo apt-get install build-essential
$ wget https://nodejs.org/dist/v10.6.0/node-v10.6.0.tar.gz
$ tar -zxvf node-v10.6.0.tar.gz
$ cd node-v10.6.0
$ make
$ sudo make install

Regards.

I've fixed this by:

  1. Cleaning cache npm cache clean -f
  2. Upgrading node to latest version: nvm install <version>
  3. Upgrading npm to latest version: npm i -g npm
  4. Removing dependencies: rm -rf node_modules
  5. Installing dependencies again: npm install

Use sudo when switching node version with n example sudo n 10.4.1

I was able to fix the issue by forcing readable-stream@2.3.0.

This is due to company network security policy

Work Around

  1. Go to https://codeload.github.com/jashkenas/underscore/zip/master and download the zip file
  2. Create underscore folder on C:\Users{YourUsername}\AppData\Roaming\npm\node_modules\underscore if you want your packge to be global
  3. Extract to folder
  4. Add "dependencies": { "underscore": "^{downloadedVersionNumber}" on you package.json file
  5. create a node_module>underscore and copy the Extract to folder

Solution for windows platform:

In my case the computer had win7 and by mistake installed a newer version of nodejs.

To solve this problem I did:

  • Starting with deleting nodesjs windows variables (system properties -> the advance tab)
  • Uninstal nodejs
  • Find the nodejs folder under program and delete it (tip: do it using cmd for faster results)
  • Enter regedit (press and hold "windows key" and letter "R" in your keyboard then type "regedit" ... Be carefull with regedit!!
  • Once regedit is open .. Edit menu then click on find
  • In the dialog box type "nodejs"
  • If it finds a key .. delete it. Press "F3" to find the next one and keep going until you delete them all.
  • In case there is one not allowing you to delete you need to enter in "save mode or with admin rights" to be able to delete those keys.
  • After that restart the computer, reinstall nodejs the newest version. It should be working fine.

That's what I did and it worked!

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!