Node.js/npm:修订间差异

来自康健生活
Kangkk​(留言 | 贡献)
Kangkk​(留言 | 贡献)
第15行: 第15行:


== 全局 ==
== 全局 ==
=== 权限 ===
如果直接全局安装会报错。
{{shc_out|<syntaxhighlight lang="bash">
npm install webpack-cli -g
</syntaxhighlight>|<syntaxhighlight lang="text">
npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules
npm WARN webpack-cli@3.3.12 requires a peer of webpack@4.x.x but none is installed. You must install peer dependencies yourself.
npm ERR! code EACCES
npm ERR! syscall access
npm ERR! path /usr/local/lib/node_modules
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, access '/usr/local/lib/node_modules'
npm ERR!  [Error: EACCES: permission denied, access '/usr/local/lib/node_modules'] {
npm ERR!  errno: -13,
npm ERR!  code: 'EACCES',
npm ERR!  syscall: 'access',
npm ERR!  path: '/usr/local/lib/node_modules'
npm ERR! }
npm ERR!
npm ERR! The operation was rejected by your operating system.
npm ERR! It is likely you do not have the permissions to access this file as the current user
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!    /home/kangjian/.npm/_logs/2020-06-27T12_46_35_227Z-debug.log
</syntaxhighlight>|$}}
安装目录添加权限
{{shc|<syntaxhighlight lang="bash">
sudo chown -R ${USER} /usr/local/lib/node_modules/
sudo chown -R ${USER} /usr/local/bin/</syntaxhighlight>|kangjian@kangkk:/usr/local/lib$}}
== 指令 ==
== 指令 ==