node.js 错误!asyncWrite 不是函数
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/50597159/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
npm ERR! asyncWrite is not a function
提问by Valyangadi Developer Support
npm install -g firebase-tools npm ERR! asyncWrite is not a function npm ERR! pna.nextTick is not a function
npm install -g firebase-tools npm ERR!asyncWrite 不是函数 npm ERR!pna.nextTick 不是函数
npm ERR! A complete log of this run can be found in: npm ERR! /home/developer/.npm/_logs/2018-05-30T05_42_20_569Z-debug.log
错误!可以在以下位置找到此运行的完整日志:npm ERR!/home/developer/.npm/_logs/2018-05-30T05_42_20_569Z-debug.log
.log data
.log 数据
/home/developer/.npm/_logs/2018-05-30T05_42_20_569Z-debug.log0 info it worked if it ends with ok
1 verbose cli [ '/usr/local/bin/node',
1 verbose cli '/usr/local/bin/npm',
1 verbose cli 'install',
1 verbose cli '-g',
1 verbose cli 'firebase-tools' ]
2 info using [email protected]
3 info using [email protected]
4 verbose npm-session 4ca1ad6ed9bde18f
5 silly install loadCurrentTree
6 silly install readGlobalPackageData
7 verbose stack TypeError: asyncWrite is not a function
7 verbose stack at onwrite (/usr/local/lib/node_modules/npm/node_modules/readable-stream/lib/_stream_writable.js:480:7)
7 verbose stack at WritableState.onwrite (/usr/local/lib/node_modules/npm/node_modules/readable-stream/lib/_stream_writable.js:180:5)
7 verbose stack at WriteStream.to [as _worker] (/usr/local/lib/node_modules/npm/node_modules/pacote/node_modules/make-fetch-happen/cache.js:154:13)
7 verbose stack at WriteStream._write (/usr/local/lib/node_modules/npm/node_modules/mississippi/node_modules/flush-write-stream/index.js:35:13)
7 verbose stack at doWrite (/usr/local/lib/node_modules/npm/node_modules/readable-stream/lib/_stream_writable.js:428:64)
7 verbose stack at writeOrBuffer (/usr/local/lib/node_modules/npm/node_modules/readable-stream/lib/_stream_writable.js:417:5)
7 verbose stack at WriteStream.Writable.write (/usr/local/lib/node_modules/npm/node_modules/readable-stream/lib/_stream_writable.js:334:11)
7 verbose stack at WriteStream.to [as _worker] (/usr/local/lib/node_modules/npm/node_modules/pacote/node_modules/make-fetch-happen/cache.js:171:25)
7 verbose stack at WriteStream._write (/usr/local/lib/node_modules/npm/node_modules/mississippi/node_modules/flush-write-stream/index.js:35:13)
7 verbose stack at doWrite (/usr/local/lib/node_modules/npm/node_modules/readable-stream/lib/_stream_writable.js:428:64)
7 verbose stack at writeOrBuffer (/usr/local/lib/node_modules/npm/node_modules/readable-stream/lib/_stream_writable.js:417:5)
7 verbose stack at WriteStream.Writable.write (/usr/local/lib/node_modules/npm/node_modules/readable-stream/lib/_stream_writable.js:334:11)
7 verbose stack at WriteStream.to [as _worker] (/usr/local/lib/node_modules/npm/node_modules/pacote/node_modules/make-fetch-happen/cache.js:182:19)
7 verbose stack at WriteStream._write (/usr/local/lib/node_modules/npm/node_modules/mississippi/node_modules/flush-write-stream/index.js:35:13)
7 verbose stack at doWrite (/usr/local/lib/node_modules/npm/node_modules/readable-stream/lib/_stream_writable.js:428:64)
7 verbose stack at writeOrBuffer (/usr/local/lib/node_modules/npm/node_modules/readable-stream/lib/_stream_writable.js:417:5)
8 verbose cwd /home/developer/Development/host2
9 verbose Linux 4.15.0-22-generic
10 verbose argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "-g" "firebase-tools"
11 verbose node v10.3.0
12 verbose npm v6.1.0
13 error asyncWrite is not a function
14 verbose exit [ 1, true ]
npm -v :6.1.0
node -v :v10.3.0
os :Ubuntu 18.04 LTS
graphics :AMD? Juniper
processor:Intel? Core? i7 CPU 960 @ 3.20GHz × 8
os type : 64-bit
npm -v :6.1.0
node -v :v10.3.0
os :Ubuntu 18.04 LTS
图形 :AMD? 瞻博
处理器:英特尔?核?i7 CPU 960 @ 3.20GHz × 8
操作系统类型:64 位
回答by Stev
The solution mentioned by DKebler did not work for me either, still got the same error and debug log.
DKebler 提到的解决方案对我也不起作用,仍然出现相同的错误和调试日志。
I had also to downgrade.
我也不得不降级。
Command Lines
命令行
sudo npm cache clean -f
sudo n 8.11.2
回答by shadowspawn
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.
n 已在 v2.1.12 中更新以解决此问题。以前,新的 npm 只是被复制到现有文件夹上。当 node_modules 的布局发生在节点 10 中时,这可能会导致问题。
Deleting npm and reinstalling will fix the npm issue. Upgrading nwill prevent the issue from happening again when switching versions using n.
删除 npm 并重新安装将解决 npm 问题。升级n将阻止使用切换版本时,再次发生的问题n。
https://github.com/tj/n/issues/508#issuecomment-423933394
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
+ [email protected]
updated 1 package in 0.466s
回答by Vyacheslav Cotruta
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:
我猜这是 npm v5 和 node v10 之间的不兼容。为了解决这个问题,我将 node 降级到 v9,将 npm 升级到 v6,然后将 node 升级到 v10:
n 9.10.1
npm i -g npm
n stable
回答by Mudassirkhan
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
那是因为,当我写这个答案时,节点 10 不太稳定。所以最好坚持使用节点 8。为此,您可以使用以下命令降级到 8.11.3
sudo n 8.11.3
then you can easily install npm modules.
然后你可以轻松安装 npm 模块。
回答by Ohgyun Ahn
Reinstalling npm -- mentioned in n installation guide-- worked for me.
重新安装 npm -在 n 安装指南中提到- 对我有用。
$ curl -0 -L https://npmjs.com/install.sh | sudo sh
回答by prinujith kj
Solution for windows platform
windows平台解决方案
- Uninstall Node
- Delete folder from programfiles if exist (C:\Program Files\nodejs)
- Delete npm's data folder: C:\Users{Your uername}\AppData\Roaming\nmp
- 卸载节点
- 如果存在,从程序文件中删除文件夹(C:\Program Files\nodejs)
- 删除 npm 的数据文件夹:C:\Users{Your uername}\AppData\Roaming\nmp
Install node Again(use different installation folder like "C:\Program Files\nodejs-2")
再次安装节点(使用不同的安装文件夹,如"C:\Program Files\nodejs-2")
Root cause is node and nvm installed in same installation folder.
根本原因是 node 和 nvm 安装在同一个安装文件夹中。
回答by Guja1501
It's versions problem. npm 6.1.0→ node 10.2.*
是版本问题。npm 6.1.0→节点10.2.*
try n 10.2.1
尝试 n 10.2.1
回答by Galois.Z
- Install an old version node, which can run success.
- Update your npm (global).
- Install the high version node.
- 安装一个老版本节点,可以运行成功。
- 更新您的 npm(全局)。
- 安装高版本节点。
The following is worked in my local environment.
以下是在我的本地环境中工作的。
First install and old version node.
首先安装和旧版本节点。
sudo n 8.11.3
sudo n 8.11.3
And then update npm.
然后更新 npm。
sudo npm i -g npm
sudo npm i -g npm
Now, you update your node, everything work fine.
现在,您更新节点,一切正常。
sudo n 10.12.0
sudo n 10.12.0
回答by Santosh Suryawanshi
You have to downgrade the node version to latest stable version i.e 8.11.2because latest version of node is not compatible yet with all npm modules.
您必须将节点版本降级到最新的稳定版本,即8.11.2因为最新版本的节点与所有 npm 模块都不兼容。
回答by mster
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:
我自己在尝试通过 npm 安装 express 时遇到了这个错误。我的简单解决方案是将节点降级到稳定版本。如果您有“n”,即节点版本管理器,则可以使用以下命令来实现:
n stable
n stable
Hopefully this helps! I highly recommend "n" if you haven't used it before. It makes life easier :)
希望这会有所帮助!如果您以前没有使用过“n”,我强烈推荐它。它让生活更轻松:)

