npm之报错:Error: EACCES: permission denied, access ‘/usr/local/lib/node_modules‘

1.报错

363 error [Error: EACCES: permission denied, rename ‘/usr/local/lib/node_modules/tldr’ -> ‘/usr/local/lib/node_modules/.tldr-8nq4AGAt’] {
363 error errno: -13,
363 error code: ‘EACCES’,
363 error syscall: ‘rename’,
363 error path: ‘/usr/local/lib/node_modules/tldr’,
363 error dest: ‘/usr/local/lib/node_modules/.tldr-8nq4AGAt’
363 error }
364 error
364 error The operation was rejected by your operating system.
364 error It is likely you do not have the permissions to access this file as the current user
364 error
364 error If you believe this might be a permissions issue, please double-check the
364 error permissions of the file and its containing directories, or try running
364 error the command again as root/Administrator.
365 verbose exit -13
366 timing npm Completed in 14226ms
367 verbose unfinished npm timer reify 1681139330501
368 verbose unfinished npm timer reify:retireShallow 1681139344576
369 verbose code -13
370 error A complete log of this run can be found in:

2.解决

# sudo chown -R $USER /usr/local/lib/node_modules
# sudo chown -R $USER /usr/local/bin
# sudo chown -R $USER /usr/local/share

3.npm更新软件

npm update -g

你可能感兴趣的:(linux,基础知识,npm,javascript,前端)