npm

npm 介绍

npm,全称为Node Package Manager,是随同NodeJS一起安装的包管理工具。


npm 命令

npm install 命令

npm install
直接使用此命令,可以将依赖项安装在本地node_modules文件夹中。
默认情况下,会安装依赖项的全部模块。

npm install <name>@<version>
使用此命令安装指定版本的依赖包,其中 name 为依赖包的名称,version为依赖包的版本。如果该版本尚未发布到注册表,则将失败。

npm install <name>@<tag>
安装指定标签引用的软件包的版本。如果该程序包的注册表数据中不存在该标记,则此操作将失败。

npm install <name>@<version range>
安装与指定版本范围匹配的软件包版本。

npm install 命令选项

options含义
-P(或者–save-prod)安装的依赖包将出现在package.json文件的dependencies中
-D(或者–save-dev)安装的依赖包将出现在package.json文件的devDependencies中
-O(或者–save-optional)安装的依赖包将出现在package.json文件的optionalDependencies中

—— END ——

npm ERR! code ERR_STREAM_DESTROYED npm ERR! Cannot call write after a stream was destroyed npm ERR! code ERR_STREAM_DESTROYED npm ERR! Cannot call write after a stream was destroyed npm ERR! code ERR_STREAM_DESTROYED npm ERR! Cannot call write after a stream was destroyed npm ERR! code EPERM npm ERR! syscall open npm ERR! path D:\Node\node_cache\_cacache\tmp\eb2d693d npm ERR! errno -4048 npm ERR! Error: EPERM: operation not permitted, open 'D:\Node\node_cache\_cacache\tmp\eb2d693d' npm ERR! [OperationalError: EPERM: operation not permitted, open 'D:\Node\node_cache\_cacache\tmp\eb2d693d'] { npm ERR! cause: [Error: EPERM: operation not permitted, open 'D:\Node\node_cache\_cacache\tmp\eb2d693d'] { npm ERR! errno: -4048, npm ERR! code: 'EPERM', npm ERR! syscall: 'open', npm ERR! path: 'D:\\Node\\node_cache\\_cacache\\tmp\\eb2d693d' npm ERR! }, npm ERR! isOperational: true, npm ERR! errno: -4048, npm ERR! code: 'EPERM', npm ERR! syscall: 'open', npm ERR! path: 'D:\\Node\\node_cache\\_cacache\\tmp\\eb2d693d' npm ERR! } npm ERR! npm ERR! The operation was rejected by your operating system. npm ERR! It's possible that the file was already in use (by a text editor or antivirus), npm ERR! or that you lack permissions to access it. npm ERR! npm ERR! If you believe this might be a permissions issue, please double-check the npm ERR! permissions of the file and its containing directories, or try running npm ERR! the command again as root/Administrator. npm ERR! code ERR_STREAM_DESTROYED npm ERR! Cannot call write after a stream was destroyed npm ERR! code ERR_STREAM_DESTROYED npm ERR! Cannot call write after a stream was destroyed npm ERR! code ERR_STREAM_DESTROYED npm ERR! Cannot call write after a stream was destroyed npm ERR! code ERR_STREAM_DESTROYED npm ERR! Cannot call write after a stream was destroyed npm ERR! code ERR_STREAM_DESTROYED npm ERR! Cannot call write after a stream was destroyed npm ERR! code ERR_STREAM_DESTROYED npm ERR! Cannot call write after a stream was destroyed npm ERR! code ERR_STREAM_DESTROYED npm ERR! Cannot call write after a stream was destroyed npm ERR! code EPERM npm ERR! syscall open npm ERR! path D:\Node\node_cache\_cacache\tmp\eb2d693d npm ERR! errno -4048 npm ERR! Error: EPERM: operation not permitted, open 'D:\Node\node_cache\_cacache\tmp\eb2d693d' npm ERR! [OperationalError: EPERM: operation not permitted, open 'D:\Node\node_cache\_cacache\tmp\eb2d693d'] { npm ERR! cause: [Error: EPERM: operation not permitted, open 'D:\Node\node_cache\_cacache\tmp\eb2d693d'] { npm ERR! errno: -4048, npm ERR! code: 'EPERM', npm ERR! syscall: 'open', npm ERR! path: 'D:\\Node\\node_cache\\_cacache\\tmp\\eb2d693d' npm ERR! }, npm ERR! isOperational: true, npm ERR! errno: -4048, npm ERR! code: 'EPERM', npm ERR! syscall: 'open', npm ERR! path: 'D:\\Node\\node_cache\\_cacache\\tmp\\eb2d693d' npm ERR! } npm ERR! npm ERR! The operation was rejected by your operating system. npm ERR! It's possible that the file was already in use (by a text editor or antivirus), npm ERR! or that you lack permissions to access it. npm ERR! npm ERR! If you believe this might be a permissions issue, please double-check the npm ERR! permissions of the file and its containing directories, or try running npm ERR! the command again as root/Administrator. npm ERR! code EPERM npm ERR! syscall open npm ERR! path D:\Node\node_cache\_cacache\tmp\a4a16f53 npm ERR! errno -4048 npm ERR! Error: EPERM: operation not permitted, open 'D:\Node\node_cache\_cacache\tmp\a4a16f53' npm ERR! [OperationalError: EPERM: operation not permitted, open 'D:\Node\node_cache\_cacache\tmp\a4a16f53'] { npm ERR! cause: [Error: EPERM: operation not permitted, open 'D:\Node\node_cache\_cacache\tmp\a4a16f53'] { npm ERR! errno: -4048, npm ERR! code: 'EPERM', npm ERR! syscall: 'open', npm ERR! path: 'D:\\Node\\node_cache\\_cacache\\tmp\\a4a16f53' npm ERR! }, npm ERR! isOperational: true, npm ERR! errno: -4048, npm ERR! code: 'EPERM', npm ERR! syscall: 'open', npm ERR! path: 'D:\\Node\\node_cache\\_cacache\\tmp\\a4a16f53' npm ERR! } npm ERR! npm ERR! The operation was rejected by your operating system. npm ERR! It's possible that the file was already in use (by a text editor or antivirus), npm ERR! or that you lack permissions to access it. npm ERR! npm ERR! If you believe this might be a permissions issue, please double-check the npm ERR! permissions of the file and its containing directories, or try running npm ERR! the command again as root/Administrator. npm WARN registry Unexpected warning for https://registry.npmjs.org/: Miscellaneous Warning EPERM: EPERM: operation not permitted, open 'D:\\Node\\node_cache\\_cacache\\tmp\\6ee0a780' npm WARN registry Using stale data from https://registry.npmjs.org/ due to a request error during revalidation. npm ERR! code ERR_STREAM_DESTROYED npm ERR! Cannot call write after a stream was destroyed npm ERR! code ERR_STREAM_DESTROYED npm ERR! Cannot call write after a stream was destroyed npm ERR! code ERR_STREAM_DESTROYED npm ERR! Cannot call write after a stream was destroyed npm ERR! code ERR_STREAM_DESTROYED npm ERR! Cannot call write after a stream was destroyed npm ERR! code EPERM npm ERR! syscall open npm ERR! path D:\Node\node_cache\_cacache\tmp\aa34d15e npm ERR! errno -4048 npm ERR! Error: EPERM: operation not permitted, open 'D:\Node\node_cache\_cacache\tmp\aa34d15e' npm ERR! [OperationalError: EPERM: operation not permitted, open 'D:\Node\node_cache\_cacache\tmp\aa34d15e'] { npm ERR! cause: [Error: EPERM: operation not permitted, open 'D:\Node\node_cache\_cacache\tmp\aa34d15e'] { npm ERR! errno: -4048, npm ERR! code: 'EPERM', npm ERR! syscall: 'open', npm ERR! path: 'D:\\Node\\node_cache\\_cacache\\tmp\\aa34d15e' npm ERR! }, npm ERR! isOperational: true, npm ERR! errno: -4048, npm ERR! code: 'EPERM', npm ERR! syscall: 'open', npm ERR! path: 'D:\\Node\\node_cache\\_cacache\\tmp\\aa34d15e' npm ERR! } npm ERR! npm ERR! The operation was rejected by your operating system. npm ERR! It's possible that the file was already in use (by a text editor or antivirus), npm ERR! or that you lack permissions to access it. npm ERR! npm ERR! If you believe this might be a permissions issue, please double-check the npm ERR! permissions of the file and its containing directories, or try running npm ERR! the command again as root/Administrator. npm ERR! code ERR_STREAM_DESTROYED npm ERR! Cannot call write after a stream was destroyed npm ERR! code ERR_STREAM_DESTROYED npm ERR! Cannot call write after a stream was destroyed npm ERR! code ERR_STREAM_DESTROYED npm ERR! Cannot call write after a stream was destroyed npm ERR! code ERR_STREAM_DESTROYED npm ERR! Cannot call write after a stream was destroyed npm ERR! code ERR_STREAM_DESTROYED npm ERR! Cannot call write after a stream was destroyed npm ERR! code ERR_STREAM_DESTROYED npm ERR! Cannot call write after a stream was destroyed npm ERR! code ERR_STREAM_DESTROYED npm ERR! Cannot call write after a stream was destroyed npm ERR! code ERR_STREAM_DESTROYED npm ERR! Cannot call write after a stream was destroyed npm ERR! code ERR_STREAM_DESTROYED npm ERR! Cannot call write after a stream was destroyed npm ERR! code ERR_STREAM_DESTROYED npm ERR! Cannot call write after a stream was destroyed npm ERR! code ERR_STREAM_DESTROYED npm ERR! Cannot call write after a stream was destroyed npm ERR! code ERR_STREAM_DESTROYED npm ERR! Cannot call write after a stream was destroyed npm ERR! code ERR_STREAM_DESTROYED npm ERR! Cannot call write after a stream was destroyed npm ERR! code EPERM npm ERR! syscall open npm ERR! path D:\Node\node_cache\_cacache\tmp\dd6cc8ed npm ERR! errno -4048 npm ERR! Error: EPERM: operation not permitted, open 'D:\Node\node_cache\_cacache\tmp\dd6cc8ed' npm ERR! [OperationalError: EPERM: operation not permitted, open 'D:\Node\node_cache\_cacache\tmp\dd6cc8ed'] { npm ERR! cause: [Error: EPERM: operation not permitted, open 'D:\Node\node_cache\_cacache\tmp\dd6cc8ed'] { npm ERR! errno: -4048, npm ERR! code: 'EPERM', npm ERR! syscall: 'open', npm ERR! path: 'D:\\Node\\node_cache\\_cacache\\tmp\\dd6cc8ed' npm ERR! }, npm ERR! isOperational: true, npm ERR! errno: -4048, npm ERR! code: 'EPERM', npm ERR! syscall: 'open', npm ERR! path: 'D:\\Node\\node_cache\\_cacache\\tmp\\dd6cc8ed' npm ERR! } npm ERR! npm ERR! The operation was rejected by your operating system. npm ERR! It's possible that the file was already in use (by a text editor or antivirus), npm ERR! or that you lack permissions to access it. npm ERR! npm ERR! If you believe this might be a permissions issue, please double-check the npm ERR! permissions of the file and its containing directories, or try running npm ERR! the command again as root/Administrator. npm ERR! code ERR_STREAM_DESTROYED npm ERR! Cannot call write after a stream was destroyed npm ERR! code ERR_STREAM_DESTROYED npm ERR! Cannot call write after a stream was destroyed npm ERR! code ERR_STREAM_DESTROYED npm ERR! Cannot call write after a stream was destroyed npm ERR! code EPERM npm ERR! syscall open npm ERR! path D:\Node\node_cache\_cacache\tmp\df92457e npm ERR! errno -4048 npm ERR! Error: EPERM: operation not permitted, open 'D:\Node\node_cache\_cacache\tmp\df92457e' npm ERR! [OperationalError: EPERM: operation not permitted, open 'D:\Node\node_cache\_cacache\tmp\df92457e'] { npm ERR! cause: [Error: EPERM: operation not permitted, open 'D:\Node\node_cache\_cacache\tmp\df92457e'] { npm ERR! errno: -4048, npm ERR! code: 'EPERM', npm ERR! syscall: 'open', npm ERR! path: 'D:\\Node\\node_cache\\_cacache\\tmp\\df92457e' npm ERR! }, npm ERR! isOperational: true, npm ERR! errno: -4048, npm ERR! code: 'EPERM', npm ERR! syscall: 'open', npm ERR! path: 'D:\\Node\\node_cache\\_cacache\\tmp\\df92457e' npm ERR! } npm ERR! npm ERR! The operation was rejected by your operating system. npm ERR! It's possible that the file was already in use (by a text editor or antivirus), npm ERR! or that you lack permissions to access it. npm ERR! npm ERR! If you believe this might be a permissions issue, please double-check the npm ERR! permissions of the file and its containing directories, or try running npm ERR! the command again as root/Administrator. npm ERR! code ERR_STREAM_DESTROYED npm ERR! Cannot call write after a stream was destroyed npm ERR! code ERR_STREAM_DESTROYED npm ERR! Cannot call write after a stream was destroyed npm ERR! code ERR_STREAM_DESTROYED npm ERR! Cannot call write after a stream was destroyed npm ERR! code EPERM npm ERR! syscall open npm ERR! path D:\Node\node_cache\_cacache\tmp\dd6cc8ed npm ERR! errno -4048 npm ERR! Error: EPERM: operation not permitted, open 'D:\Node\node_cache\_cacache\tmp\dd6cc8ed' npm ERR! [OperationalError: EPERM: operation not permitted, open 'D:\Node\node_cache\_cacache\tmp\dd6cc8ed'] { npm ERR! cause: [Error: EPERM: operation not permitted, open 'D:\Node\node_cache\_cacache\tmp\dd6cc8ed'] { npm ERR! errno: -4048, npm ERR! code: 'EPERM', npm ERR! syscall: 'open', npm ERR! path: 'D:\\Node\\node_cache\\_cacache\\tmp\\dd6cc8ed' npm ERR! }, npm ERR! isOperational: true, npm ERR! errno: -4048, npm ERR! code: 'EPERM', npm ERR! syscall: 'open', npm ERR! path: 'D:\\Node\\node_cache\\_cacache\\tmp\\dd6cc8ed' npm ERR! } npm ERR! npm ERR! The operation was rejected by your operating system. npm ERR! It's possible that the file was already in use (by a text editor or antivirus), npm ERR! or that you lack permissions to access it. npm ERR! npm ERR! If you believe this might be a permissions issue, please double-check the npm ERR! permissions of the file and its containing directories, or try running npm ERR! the command again as root/Administrator. npm ERR! code EPERM npm ERR! syscall open npm ERR! path D:\Node\node_cache\_cacache\tmp\01bdab06 npm ERR! errno -4048 npm ERR! Error: EPERM: operation not permitted, open 'D:\Node\node_cache\_cacache\tmp\01bdab06' npm ERR! [OperationalError: EPERM: operation not permitted, open 'D:\Node\node_cache\_cacache\tmp\01bdab06'] { npm ERR! cause: [Error: EPERM: operation not permitted, open 'D:\Node\node_cache\_cacache\tmp\01bdab06'] { npm ERR! errno: -4048, npm ERR! code: 'EPERM', npm ERR! syscall: 'open', npm ERR! path: 'D:\\Node\\node_cache\\_cacache\\tmp\\01bdab06' npm ERR! }, npm ERR! isOperational: true, npm ERR! errno: -4048, npm ERR! code: 'EPERM', npm ERR! syscall: 'open', npm ERR! path: 'D:\\Node\\node_cache\\_cacache\\tmp\\01bdab06' npm ERR! } npm ERR! npm ERR! The operation was rejected by your operating system. npm ERR! It's possible that the file was already in use (by a text editor or antivirus), npm ERR! or that you lack permissions to access it. npm ERR! npm ERR! If you believe this might be a permissions issue, please double-check the npm ERR! permissions of the file and its containing directories, or try running npm ERR! the command again as root/Administrator. npm ERR! code ERR_STREAM_DESTROYED npm ERR! Cannot call write after a stream was destroyed npm ERR! code ERR_STREAM_DESTROYED npm ERR! Cannot call write after a stream was destroyed npm ERR! code ERR_STREAM_DESTROYED npm ERR! Cannot call write after a stream was destroyed npm ERR! code ERR_STREAM_DESTROYED npm ERR! Cannot call write after a stream was destroyed npm ERR! code ERR_STREAM_DESTROYED npm ERR! Cannot call write after a stream was destroyed npm ERR! code ERR_STREAM_DESTROYED npm ERR! Cannot call write after a stream was destroyed npm ERR! code ERR_STREAM_DESTROYED npm ERR! Cannot call write after a stream was destroyed npm ERR! code ERR_STREAM_DESTROYED npm ERR! Cannot call write after a stream was destroyed npm ERR! code ERR_STREAM_DESTROYED npm ERR! Cannot call write after a stream was destroyed npm ERR! code ERR_STREAM_DESTROYED npm ERR! Cannot call write after a stream was destroyed npm ERR! code ERR_STREAM_DESTROYED npm ERR! Cannot call write after a stream was destroyed npm ERR! code ERR_STREAM_DESTROYED npm ERR! Cannot call write after a stream was destroyed npm ERR! code EPERM npm ERR! syscall open npm ERR! path D:\Node\node_cache\_cacache\tmp\eb849235 npm ERR! errno -4048 npm ERR! Error: EPERM: operation not permitted, open 'D:\Node\node_cache\_cacache\tmp\eb849235' npm ERR! [OperationalError: EPERM: operation not permitted, open 'D:\Node\node_cache\_cacache\tmp\eb849235'] { npm ERR! cause: [Error: EPERM: operation not permitted, open 'D:\Node\node_cache\_cacache\tmp\eb849235'] { npm ERR! errno: -4048, npm ERR! code: 'EPERM', npm ERR! syscall: 'open', npm ERR! path: 'D:\\Node\\node_cache\\_cacache\\tmp\\eb849235' npm ERR! }, npm ERR! isOperational: true, npm ERR! errno: -4048, npm ERR! code: 'EPERM', npm ERR! syscall: 'open', npm ERR! path: 'D:\\Node\\node_cache\\_cacache\\tmp\\eb849235' npm ERR! } npm ERR! npm ERR! The operation was rejected by your operating system. npm ERR! It's possible that the file was already in use (by a text editor or antivirus), npm ERR! or that you lack permissions to access it. npm ERR! npm ERR! If you believe this might be a permissions issue, please double-check the npm ERR! permissions of the file and its containing directories, or try running npm ERR! the command again as root/Administrator. npm ERR! code ERR_STREAM_DESTROYED npm ERR! Cannot call write after a stream was destroyed npm ERR! code ERR_STREAM_DESTROYED npm ERR! Cannot call write after a stream was destroyed npm ERR! code ERR_STREAM_DESTROYED npm ERR! Cannot call write after a stream was destroyed npm ERR! code ERR_STREAM_DESTROYED npm ERR! Cannot call write after a stream was destroyed npm ERR! code ERR_STREAM_DESTROYED npm ERR! Cannot call write after a stream was destroyed npm ERR! code ERR_STREAM_DESTROYED npm ERR! Cannot call write after a stream was destroyed npm ERR! code ERR_STREAM_DESTROYED npm ERR! Cannot call write after a stream was destroyed npm ERR! code ERR_STREAM_DESTROYED npm ERR! Cannot call write after a stream was destroyed npm ERR! code ERR_STREAM_DESTROYED npm ERR! Cannot call write after a stream was destroyed npm ERR! code EPERM npm ERR! syscall open npm ERR! path D:\Node\node_cache\_cacache\tmp\df92457e npm ERR! errno -4048 npm ERR! Error: EPERM: operation not permitted, open 'D:\Node\node_cache\_cacache\tmp\df92457e' npm ERR! [OperationalError: EPERM: operation not permitted, open 'D:\Node\node_cache\_cacache\tmp\df92457e'] { npm ERR! cause: [Error: EPERM: operation not permitted, open 'D:\Node\node_cache\_cacache\tmp\df92457e'] { npm ERR! errno: -4048, npm ERR! code: 'EPERM', npm ERR! syscall: 'open', npm ERR! path: 'D:\\Node\\node_cache\\_cacache\\tmp\\df92457e' npm ERR! }, npm ERR! isOperational: true, npm ERR! errno: -4048, npm ERR! code: 'EPERM', npm ERR! syscall: 'open', npm ERR! path: 'D:\\Node\\node_cache\\_cacache\\tmp\\df92457e' npm ERR! } npm ERR! npm ERR! The operation was rejected by your operating system. npm ERR! It's possible that the file was already in use (by a text editor or antivirus), npm ERR! or that you lack permissions to access it. npm ERR! npm ERR! If you believe this might be a permissions issue, please double-check the npm ERR! permissions of the file and its containing directories, or try running npm ERR! the command again as root/Administrator. npm ERR! code ERR_STREAM_DESTROYED npm ERR! Cannot call write after a stream was destroyed npm ERR! code ERR_STREAM_DESTROYED npm ERR! Cannot call write after a stream was destroyed npm ERR! code ERR_STREAM_DESTROYED npm ERR! Cannot call write after a stream was destroyed npm ERR! code ERR_STREAM_DESTROYED npm ERR! Cannot call write after a stream was destroyed npm ERR! code ERR_STREAM_DESTROYED npm ERR! Cannot call write after a stream was destroyed npm ERR! code ERR_STREAM_DESTROYED npm ERR! Cannot call write after a stream was destroyed npm ERR! code ERR_STREAM_DESTROYED npm ERR! Cannot call write after a stream was destroyed npm ERR! code ERR_STREAM_DESTROYED npm ERR! Cannot call write after a stream was destroyed npm ERR! code ERR_STREAM_DESTROYED npm ERR! Cannot call write after a stream was destroyed npm ERR! code ERR_STREAM_DESTROYED npm ERR! Cannot call write after a stream was destroyed npm ERR! code ERR_STREAM_DESTROYED npm ERR! Cannot call write after a stream was destroyed npm ERR! code EPERM npm ERR! syscall open npm ERR! path D:\Node\node_cache\_cacache\tmp\3688e03a npm ERR! errno -4048 npm ERR! Error: EPERM: operation not permitted, open 'D:\Node\node_cache\_cacache\tmp\3688e03a' npm ERR! [OperationalError: EPERM: operation not permitted, open 'D:\Node\node_cache\_cacache\tmp\3688e03a'] { npm ERR! cause: [Error: EPERM: operation not permitted, open 'D:\Node\node_cache\_cacache\tmp\3688e03a'] { npm ERR! errno: -4048, npm ERR! code: 'EPERM', npm ERR! syscall: 'open', npm ERR! path: 'D:\\Node\\node_cache\\_cacache\\tmp\\3688e03a' npm ERR! }, npm ERR! isOperational: true, npm ERR! errno: -4048, npm ERR! code: 'EPERM', npm ERR! syscall: 'open', npm ERR! path: 'D:\\Node\\node_cache\\_cacache\\tmp\\3688e03a' npm ERR! } npm ERR! npm ERR! The operation was rejected by your operating system. npm ERR! It's possible that the file was already in use (by a text editor or antivirus), npm ERR! or that you lack permissions to access it. npm ERR! npm ERR! If you believe this might be a permissions issue, please double-check the npm ERR! permissions of the file and its containing directories, or try running npm ERR! the command again as root/Administrator. npm ERR! code ERR_STREAM_DESTROYED npm ERR! Cannot call write after a stream was destroyed npm ERR! code ERR_STREAM_DESTROYED npm ERR! Cannot call write after a stream was destroyed npm ERR! code ERR_STREAM_DESTROYED npm ERR! Cannot call write after a stream was destroyed npm ERR! code ERR_STREAM_DESTROYED npm ERR! Cannot call write after a stream was destroyed npm ERR! code ERR_STREAM_DESTROYED npm ERR! Cannot call write after a stream was destroyed npm ERR! code ERR_STREAM_DESTROYED npm ERR! Cannot call write after a stream was destroyed npm ERR! code ERR_STREAM_DESTROYED npm ERR! Cannot call write after a stream was destroyed npm ERR! code ERR_STREAM_DESTROYED npm ERR! Cannot call write after a stream was destroyed npm ERR! code EPERM npm ERR! syscall open npm ERR! path D:\Node\node_cache\_cacache\tmp\35daa67e npm ERR! errno -4048 npm ERR! Error: EPERM: operation not permitted, open 'D:\Node\node_cache\_cacache\tmp\35daa67e' npm ERR! [OperationalError: EPERM: operation not permitted, open 'D:\Node\node_cache\_cacache\tmp\35daa67e'] { npm ERR! cause: [Error: EPERM: operation not permitted, open 'D:\Node\node_cache\_cacache\tmp\35daa67e'] { npm ERR! errno: -4048, npm ERR! code: 'EPERM', npm ERR! syscall: 'open', npm ERR! path: 'D:\\Node\\node_cache\\_cacache\\tmp\\35daa67e' npm ERR! }, npm ERR! isOperational: true, npm ERR! errno: -4048, npm ERR! code: 'EPERM', npm ERR! syscall: 'open', npm ERR! path: 'D:\\Node\\node_cache\\_cacache\\tmp\\35daa67e' npm ERR! } npm ERR! npm ERR! The operation was rejected by your operating system. npm ERR! It's possible that the file was already in use (by a text editor or antivirus), npm ERR! or that you lack permissions to access it. npm ERR! npm ERR! If you believe this might be a permissions issue, please double-check the npm ERR! permissions of the file and its containing directories, or try running npm ERR! the command again as root/Administrator. npm ERR! code ERR_STREAM_DESTROYED npm ERR! Cannot call write after a stream was destroyed npm ERR! code ERR_STREAM_DESTROYED npm ERR! Cannot call write after a stream was destroyed npm ERR! code ERR_STREAM_DESTROYED npm ERR! Cannot call write after a stream was destroyed npm ERR! code ERR_STREAM_DESTROYED npm ERR! Cannot call write after a stream was destroyed npm ERR! code ERR_STREAM_DESTROYED npm ERR! Cannot call write after a stream was destroyed npm ERR! code ERR_STREAM_DESTROYED npm ERR! Cannot call write after a stream was destroyed npm ERR! code ERR_STREAM_DESTROYED npm ERR! Cannot call write after a stream was destroyed npm ERR! code ERR_STREAM_DESTROYED npm ERR! Cannot call write after a stream was destroyed npm ERR! code ERR_STREAM_DESTROYED npm ERR! Cannot call write after a stream was destroyed npm ERR! code ERR_STREAM_DESTROYED npm ERR! Cannot call write after a stream was destroyed npm ERR! code ERR_STREAM_DESTROYED npm ERR! Cannot call write after a stream was destroyed npm ERR! code ERR_STREAM_DESTROYED npm ERR! Cannot call write after a stream was destroyed npm ERR! code ERR_STREAM_DESTROYED npm ERR! Cannot call write after a stream was destroyed npm ERR! code ERR_STREAM_DESTROYED npm ERR! Cannot call write after a stream was destroyed npm ERR! code ERR_STREAM_DESTROYED npm ERR! Cannot call write after a stream was destroyed npm ERR! code ERR_STREAM_DESTROYED npm ERR! Cannot call write after a stream was destroyed npm ERR! code ERR_STREAM_DESTROYED npm ERR! Cannot call write after a stream was destroyed npm ERR! code ERR_STREAM_DESTROYED npm ERR! Cannot call write after a stream was destroyed npm ERR! code ERR_STREAM_DESTROYED npm ERR! Cannot call write after a stream was destroyed npm ERR! code ERR_STREAM_DESTROYED npm ERR! Cannot call write after a stream was destroyed npm ERR! code ERR_STREAM_DESTROYED npm ERR! Cannot call write after a stream was destroyed npm ERR! code ERR_STREAM_DESTROYED npm ERR! Cannot call write after a stream was destroyed npm ERR! code ERR_STREAM_DESTROYED npm ERR! Cannot call write after a stream was destroyed npm ERR! code ERR_STREAM_DESTROYED npm ERR! Cannot call write after a stream was destroyed npm ERR! code ERR_STREAM_DESTROYED npm ERR! Cannot call write after a stream was destroyed npm ERR! code EPERM npm ERR! syscall open npm ERR! path D:\Node\node_cache\_cacache\tmp\35daa67e npm ERR! errno -4048 npm ERR! Error: EPERM: operation not permitted, open 'D:\Node\node_cache\_cacache\tmp\35daa67e' npm ERR! [OperationalError: EPERM: operation not permitted, open 'D:\Node\node_cache\_cacache\tmp\35daa67e'] { npm ERR! cause: [Error: EPERM: operation not permitted, open 'D:\Node\node_cache\_cacache\tmp\35daa67e'] { npm ERR! errno: -4048, npm ERR! code: 'EPERM', npm ERR! syscall: 'open', npm ERR! path: 'D:\\Node\\node_cache\\_cacache\\tmp\\35daa67e' npm ERR! }, npm ERR! isOperational: true, npm ERR! errno: -4048, npm ERR! code: 'EPERM', npm ERR! syscall: 'open', npm ERR! path: 'D:\\Node\\node_cache\\_cacache\\tmp\\35daa67e' npm ERR! } npm ERR! npm ERR! The operation was rejected by your operating system. npm ERR! It's possible that the file was already in use (by a text editor or antivirus), npm ERR! or that you lack permissions to access it. npm ERR! npm ERR! If you believe this might be a permissions issue, please double-check the npm ERR! permissions of the file and its containing directories, or try running npm ERR! the command again as root/Administrator. npm ERR! code EPERM npm ERR! syscall open npm ERR! path D:\Node\node_cache\_cacache\tmp\01bdab06 npm ERR! errno -4048 npm ERR! Error: EPERM: operation not permitted, open 'D:\Node\node_cache\_cacache\tmp\01bdab06' npm ERR! [OperationalError: EPERM: operation not permitted, open 'D:\Node\node_cache\_cacache\tmp\01bdab06'] { npm ERR! cause: [Error: EPERM: operation not permitted, open 'D:\Node\node_cache\_cacache\tmp\01bdab06'] { npm ERR! errno: -4048, npm ERR! code: 'EPERM', npm ERR! syscall: 'open', npm ERR! path: 'D:\\Node\\node_cache\\_cacache\\tmp\\01bdab06' npm ERR! }, npm ERR! isOperational: true, npm ERR! errno: -4048, npm ERR! code: 'EPERM', npm ERR! syscall: 'open', npm ERR! path: 'D:\\Node\\node_cache\\_cacache\\tmp\\01bdab06' npm ERR! } npm ERR! npm ERR! The operation was rejected by your operating system. npm ERR! It's possible that the file was already in use (by a text editor or antivirus), npm ERR! or that you lack permissions to access it. npm ERR! npm ERR! If you believe this might be a permissions issue, please double-check the npm ERR! permissions of the file and its containing directories, or try running npm ERR! the command again as root/Administrator. npm ERR! code EPERM npm ERR! syscall open npm ERR! path D:\Node\node_cache\_cacache\tmp\884bfc72 npm ERR! errno -4048 npm ERR! Error: EPERM: operation not permitted, open 'D:\Node\node_cache\_cacache\tmp\884bfc72' npm ERR! [OperationalError: EPERM: operation not permitted, open 'D:\Node\node_cache\_cacache\tmp\884bfc72'] { npm ERR! cause: [Error: EPERM: operation not permitted, open 'D:\Node\node_cache\_cacache\tmp\884bfc72'] { npm ERR! errno: -4048, npm ERR! code: 'EPERM', npm ERR! syscall: 'open', npm ERR! path: 'D:\\Node\\node_cache\\_cacache\\tmp\\884bfc72' npm ERR! }, npm ERR! isOperational: true, npm ERR! errno: -4048, npm ERR! code: 'EPERM', npm ERR! syscall: 'open', npm ERR! path: 'D:\\Node\\node_cache\\_cacache\\tmp\\884bfc72' npm ERR! } npm ERR! npm ERR! The operation was rejected by your operating system. npm ERR! It's possible that the file was already in use (by a text editor or antivirus), npm ERR! or that you lack permissions to access it. npm ERR! npm ERR! If you believe this might be a permissions issue, please double-check the npm ERR! permissions of the file and its containing directories, or try running npm ERR! the command again as root/Administrator. npm ERR! code ERR_STREAM_DESTROYED npm ERR! Cannot call write after a stream was destroyed npm ERR! code ERR_STREAM_DESTROYED npm ERR! Cannot call write after a stream was destroyed npm ERR! code ERR_STREAM_DESTROYED npm ERR! Cannot call write after a stream was destroyed npm ERR! code ERR_STREAM_DESTROYED npm ERR! Cannot call write after a stream was destroyed npm ERR! code ERR_STREAM_DESTROYED npm ERR! Cannot call write after a stream was destroyed npm ERR! code ERR_STREAM_DESTROYED npm ERR! Cannot call write after a stream was destroyed npm ERR! code ERR_STREAM_DESTROYED npm ERR! Cannot call write after a stream was destroyed npm ERR! code ERR_STREAM_DESTROYED npm ERR! Cannot call write after a stream was destroyed npm ERR! code ERR_STREAM_DESTROYED npm ERR! Cannot call write after a stream was destroyed npm ERR! code ERR_STREAM_DESTROYED npm ERR! Cannot call write after a stream was destroyed npm ERR! code ERR_STREAM_DESTROYED npm ERR! Cannot call write after a stream was destroyed npm ERR! code ERR_STREAM_DESTROYED npm ERR! Cannot call write after a stream was destroyed npm ERR! code ERR_STREAM_DESTROYED npm ERR! Cannot call write after a stream was destroyed npm ERR! code ERR_STREAM_DESTROYED npm ERR! Cannot call write after a stream was destroyed npm ERR! code EPERM npm ERR! syscall open npm ERR! path D:\Node\node_cache\_cacache\tmp\aa34d15e npm ERR! errno -4048 npm ERR! Error: EPERM: operation not permitted, open 'D:\Node\node_cache\_cacache\tmp\aa34d15e' npm ERR! [OperationalError: EPERM: operation not permitted, open 'D:\Node\node_cache\_cacache\tmp\aa34d15e'] { npm ERR! cause: [Error: EPERM: operation not permitted, open 'D:\Node\node_cache\_cacache\tmp\aa34d15e'] { npm ERR! errno: -4048, npm ERR! code: 'EPERM', npm ERR! syscall: 'open', npm ERR! path: 'D:\\Node\\node_cache\\_cacache\\tmp\\aa34d15e' npm ERR! }, npm ERR! isOperational: true, npm ERR! errno: -4048, npm ERR! code: 'EPERM', npm ERR! syscall: 'open', npm ERR! path: 'D:\\Node\\node_cache\\_cacache\\tmp\\aa34d15e' npm ERR! } npm ERR! npm ERR! The operation was rejected by your operating system. npm ERR! It's possible that the file was already in use (by a text editor or antivirus), npm ERR! or that you lack permissions to access it. npm ERR! npm ERR! If you believe this might be a permissions issue, please double-check the npm ERR! permissions of the file and its containing directories, or try running npm ERR! the command again as root/Administrator. npm ERR! code ERR_STREAM_DESTROYED npm ERR! Cannot call write after a stream was destroyed npm ERR! code ERR_STREAM_DESTROYED npm ERR! Cannot call write after a stream was destroyed npm ERR! code ERR_STREAM_DESTROYED npm ERR! Cannot call write after a stream was destroyed npm ERR! code ERR_STREAM_DESTROYED npm ERR! Cannot call write after a stream was destroyed npm ERR! code ERR_STREAM_DESTROYED npm ERR! Cannot call write after a stream was destroyed npm ERR! code ERR_STREAM_DESTROYED npm ERR! Cannot call write after a stream was destroyed npm ERR! code ERR_STREAM_DESTROYED npm ERR! Cannot call write after a stream was destroyed npm ERR! code ERR_STREAM_DESTROYED npm ERR! Cannot call write after a stream was destroyed npm ERR! code ERR_STREAM_DESTROYED npm ERR! Cannot call write after a stream was destroyed npm ERR! code ERR_STREAM_DESTROYED npm ERR! Cannot call write after a stream was destroyed npm ERR! code ERR_STREAM_DESTROYED npm ERR! Cannot call write after a stream was destroyed npm ERR! code ERR_STREAM_DESTROYED npm ERR! Cannot call write after a stream was destroyed npm ERR! code ERR_STREAM_DESTROYED npm ERR! Cannot call write after a stream was destroyed npm ERR! code ERR_STREAM_DESTROYED npm ERR! Cannot call write after a stream was destroyed npm ERR! code ERR_STREAM_DESTROYED npm ERR! Cannot call write after a stream was destroyed npm ERR! code ERR_STREAM_DESTROYED npm ERR! Cannot call write after a stream was destroyed npm ERR! code ERR_STREAM_DESTROYED npm ERR! Cannot call write after a stream was destroyed npm ERR! code ERR_STREAM_DESTROYED npm ERR! Cannot call write after a stream was destroyed npm ERR! code ERR_STREAM_DESTROYED npm ERR! Cannot call write after a stream was destroyed npm ERR! code ERR_STREAM_DESTROYED npm ERR! Cannot call write after a stream was destroyed npm ERR! code ERR_STREAM_DESTROYED npm ERR! Cannot call write after a stream was destroyed npm ERR! code ERR_STREAM_DESTROYED npm ERR! Cannot call write after a stream was destroyed npm ERR! code ERR_STREAM_DESTROYED npm ERR! Cannot call write after a stream was destroyed npm ERR! code ERR_STREAM_DESTROYED npm ERR! Cannot call write after a stream was destroyed npm ERR! code ERR_STREAM_DESTROYED npm ERR! Cannot call write after a stream was destroyed npm ERR! code ERR_STREAM_DESTROYED npm ERR! Cannot call write after a stream was destroyed npm ERR! code ERR_STREAM_DESTROYED npm ERR! Cannot call write after a stream was destroyed npm ERR! code ERR_STREAM_DESTROYED npm ERR! Cannot call write after a stream was destroyed npm ERR! code EPERM npm ERR! syscall open npm ERR! path D:\Node\node_cache\_cacache\tmp\3688e03a npm ERR! errno -4048 npm ERR! Error: EPERM: operation not permitted, open 'D:\Node\node_cache\_cacache\tmp\3688e03a' npm ERR! [OperationalError: EPERM: operation not permitted, open 'D:\Node\node_cache\_cacache\tmp\3688e03a'] { npm ERR! cause: [Error: EPERM: operation not permitted, open 'D:\Node\node_cache\_cacache\tmp\3688e03a'] { npm ERR! errno: -4048, npm ERR! code: 'EPERM', npm ERR! syscall: 'open', npm ERR! path: 'D:\\Node\\node_cache\\_cacache\\tmp\\3688e03a' npm ERR! }, npm ERR! isOperational: true, npm ERR! errno: -4048, npm ERR! code: 'EPERM', npm ERR! syscall: 'open', npm ERR! path: 'D:\\Node\\node_cache\\_cacache\\tmp\\3688e03a' npm ERR! } npm ERR! npm ERR! The operation was rejected by your operating system. npm ERR! It's possible that the file was already in use (by a text editor or antivirus), npm ERR! or that you lack permissions to access it. npm ERR! npm ERR! If you believe this might be a permissions issue, please double-check the npm ERR! permissions of the file and its containing directories, or try running npm ERR! the command again as root/Administrator.
最新发布
05-16
### 解决 Windows 系统中 npm 运行时出现的 EPERM 和 ERR_STREAM_DESTROYED 问题 在使用 `vue-cli-service serve` 启动项目时,可能会因为权限不足(EPERM)或流被销毁(ERR_STREAM_DESTROYED)而遇到错误。以下是针对这两种问题的具体分析与解决方案。 --- #### **1. 处理 EPERM 错误** EPERM 是一种操作系统级别的权限错误,通常发生在尝试访问受保护资源时缺乏必要权限的情况下。 - **原因**: - 尝试写入无权操作的文件夹。 - 使用了受限路径作为全局包存储位置。 - 文件系统损坏或磁盘空间不足。 - **解决方法**: - **以管理员身份运行 CMD 或 PowerShell**:右键点击终端图标并选择“以管理员身份运行”,然后重新执行命令[^1]。 ```bash npm install -g @vue/cli ``` - **修改 npm 全局包默认路径**:将全局包安装目录更改为用户有权访问的位置。 - 查看当前全局路径: ```bash npm config get prefix ``` - 设置新的全局路径(例如设置为用户的本地 AppData 目录): ```bash npm config set prefix "%USERPROFILE%\.npm-global" ``` - 将新路径添加到系统的 PATH 环境变量中: ``` %USERPROFILE%\.npm-global\bin ``` - **清理缓存并重置配置**:有时候缓存中的数据可能导致权限问题。 ```bash npm cache clean --force npm config edit ``` --- #### **2. 处理 ERR_STREAM_DESTROYED 错误** 此错误通常是由于底层 I/O 流被意外关闭引起的,可能是由以下原因之一导致: - **原因**: - Webpack 编译过程中发生中断。 - 源码变更触发热更新机制失败。 - 文件监视器未能正确捕获变化事件。 - **解决方法**: - **禁用文件监控功能**:对于频繁抛出异常的情况,可以通过参数禁用文件监听。 ```bash vue-cli-service serve --no-clear ``` - **调整文件监听策略**:部分开发者工具可能对大文件或复杂结构敏感,可通过增加超时时间缓解。 - 修改 `webpack.config.js` 中的相关选项: ```javascript module.exports = { devServer: { watchOptions: { poll: true, // 开启轮询模式 ignored: /node_modules/, // 忽略不必要的文件夹 }, }, }; ``` - 如果使用的是 Vue CLI 默认配置,可以在 `vue.config.js` 中定义类似的属性: ```javascript module.exports = { devServer: { watchOptions: { aggregateTimeout: 300, poll: 1000, }, }, }; ``` - **修复潜在的依赖冲突**:某些情况下,特定版本间的不兼容也可能引起该类问题。 - 强制忽略 peerDependencies 冲突: ```bash npm install --legacy-peer-deps ``` - 清除现有依赖并重新构建: ```bash rm -rf node_modules package-lock.json npm install ``` --- #### **3. 综合建议** 为了减少类似问题的发生频率,推荐采取以下预防措施: - 定期更新 Node.js 和 NPM 至最新稳定版本。 - 配置 `.npmrc` 文件优化下载体验,比如指定淘宝镜像源: ```ini registry=https://registry.npmmirror.com/ ``` - 对重要项目启用 Git 版本控制,便于回滚至正常状态。 --- ### 示例代码片段 以下是一个简单的脚本用于检测和修正常见的 npm 配置问题: ```bash #!/bin/bash echo "Checking global npm permissions..." if ! npm config get prefix | grep -q "$HOME"; then echo "Setting safe global prefix..." npm config set prefix "$HOME/.npm-global" fi echo "Clearing old caches and reinstall dependencies..." npm cache clean --force rm -rf node_modules package-lock.json npm install --legacy-peer-deps ``` ---
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值