Javascript 错误:npm 错误!在结束后写
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/49148753/
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
Error: npm ERR! write after end
提问by Clément Jolliet
I am having issues installing Cordovaand 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 endthen everytime I try to install cordova ionic, I've got the same error for a different package ...
Here are errors I get :
我在安装Cordova和Ionic时遇到问题 。起初我不能,因为安装似乎已损坏,这导致我卸载了 NodeJS - Cordova - Ionic。
现在,我已经重新安装了 NodeJS,没有问题,但是当涉及到著名的行时:npm install -g cordova ionic,我遇到了这个错误:npm ERR! write after end然后每次我尝试安装cordova ionic 时,对于不同的包,我都会遇到相同的错误......
这是我得到的错误:
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\_logs18-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\_logs18-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\_logs18-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 :
编辑 1 :安装一些软件包并重试后,我现在得到了这个:
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)
回答by Melchia
Try installing latest npm version this happens a lot with ionic.
尝试安装最新的 npm 版本,这在 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 linkto download YARN.
After installing just run this command yarn global add cordova ionic
如果这不起作用,我建议您切换到纱线。它更快更容易使用。这是下载 YARN的链接。安装后只需运行此命令 yarn global add cordova ionic
Ionic CLI uses npm by default. So go to your project & run $ yarn install.
Ionic CLI 默认使用 npm。所以去你的项目并运行$ yarn install.
If you want Ionic to use yarn by default run this: $ ionic config set -g yarn true
如果您希望 Ionic 默认使用 yarn,请运行以下命令: $ ionic config set -g yarn true
回答by marked.
In my case, I didn't downgrade my npm because it will cause chaos in other dependencies. Instead, I tried running
就我而言,我没有降级我的 npm,因为它会导致其他依赖项的混乱。相反,我试着跑
npm cache verify
Error gone...
错误消失了...
回答by AddWeb Solution Pvt Ltd
Let, update the latest version of npm for running this command,
让,更新最新版本的 npm 以运行此命令,
npm install npm@latest -g
Then run this command,
然后运行这个命令,
npm install -g cordova ionic
回答by Alex Lu
It happened to me when I tried to install a ionic3 project with [email protected], well I solved this issue just add some params, use the following:
当我尝试使用 [email protected] 安装 ionic3 项目时发生在我身上,我解决了这个问题,只需添加一些参数,使用以下内容:
npm i --unsafe-perm
and it works.
它有效。
回答by Lee De Blade
i faced the same issue. For my case, i update npm to latest 6.1.0 by running "npm install -g npm@latest". Then run "npm cache verify
我遇到了同样的问题。就我而言,我通过运行“npm install -g npm@latest”将 npm 更新到最新的 6.1.0。然后运行“npm cache verify
回答by Sorabh Mendiratta
This still happens randomly on some npm versions. Issue got resolved on downgrading to npm version 5.6.0 using command
这仍然会在某些 npm 版本上随机发生。使用命令降级到 npm 版本 5.6.0 时问题得到解决
npm install -g [email protected]
Hope that will help someone.
希望这会帮助某人。
回答by chebaby
Update July 28, 2018
2018 年 7 月 28 日更新
This problem is related to npm version 5.7.1
此问题与 npm 5.7.1版本有关
Upgrading to node version 8.11.3with npm version 5.8.0solve the problem
使用 npm 版本5.8.0升级到 node 版本8.11.3解决问题
回答by Yamen Ashraf
Just run
npm cache verify
赶紧跑
npm cache verify
This will clean it all.
这将清除所有内容。
回答by Ahmed Elkoussy
Usually this error is due to your Antivirusblocking access to changing the files, to solve this:
通常此错误是由于您的防病毒软件阻止访问更改文件,以解决此问题:
1- You can try to turn your Antivirus off (temporarily) & try the installation again
1-您可以尝试关闭防病毒软件(暂时)并再次尝试安装
2- If that alone doesn't work, try using the --force option while installing
2- 如果单独这样做不起作用,请在安装时尝试使用 --force 选项
I had this issue with some packages & it was solved by using one of the 2 steps above.
我在某些软件包中遇到了这个问题,并通过使用上述 2 个步骤之一解决了这个问题。
For example:
例如:
npm install -g cordova ionic --force
回答by kdg1955
None of the previous answers could help me.
以前的答案都不能帮助我。
Fortunately, after a lot of 'try and error', I found the following simple solution:
幸运的是,经过大量的“尝试和错误”之后,我找到了以下简单的解决方案:
- delete (or move) the file 'package-lock.json' and
npm installworks flawlessly.
- 删除(或移动)文件“ package-lock.json”并
npm install完美运行。
Tip: if you have your project in a git repository:
提示:如果您的项目在 git 存储库中:
- add the file 'package-lock.json' in '.gitignore'
- 在“.gitignore”中添加文件“ package-lock.json”

