使用npm链接命令时出现错误

时间:2020-03-27 07:17:25

标签: javascript node.js npm npm-link

我正在尝试在Windows计算机上使用npm link命令,但是遇到此错误可以帮助我,这方面我已经停留了一段时间了

npm ERR! code EPERM
npm ERR! syscall symlink
npm ERR! path C:\projects\app
npm ERR! dest C:\Program Files\nodejs\node_modules\lists
npm ERR! errno -4048
npm ERR! Error: EPERM: operation not permitted, symlink 'C:\projects\app' -> 'C:\Program Files\nodejs\node_modules\lists'
npm ERR!  { [Error: EPERM: operation not permitted, symlink 'C:\projects\app' -> 'C:\Program Files\nodejs\node_modules\lists']
npm ERR!   stack:
npm ERR!    'Error: EPERM: operation not permitted, symlink 'C:\projects\app' -> 'C:\Program Files\nodejs\node_modules\lists'',
npm ERR!   errno: -4048,
npm ERR!   code: 'EPERM',
npm ERR!   syscall: 'symlink',
npm ERR!   path: 'C:\projects\app',
npm ERR!   dest: 'C:\Program Files\nodejs\node_modules\lists' }
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! A complete log of this run can be found in:
npm ERR!     C:\Users\user\AppData\Roaming\npm-cache_logs\2020-03-27T06_37_20_042Z-debug.log

1 个答案:

答案 0 :(得分:0)

npm链接命令必须以管理员权限运行。

如果您正在运行Windows,则可以点击以下链接:https://www.isunshare.com/windows-10/2-ways-to-run-command-prompt-as-administrator-in-win-10.html

对于基于Unix的平台,您可以在命令的第一行添加 sudo