alibaba / rax

🐰 Rax is a progressive framework for building universal application. https://rax.js.org
Other
7.99k stars 627 forks source link

[BUG]npm init rax <YourProjectName>命令提示权限问题,用sudo还是不行 #2230

Closed cyaolong closed 3 years ago

cyaolong commented 3 years ago

Describe the bug https://openkraken.com/guide/development/rax,按照文档描述输入命令行后提示权限问题,用了 sudo npm init rax demo --unsafe-perm 还是不行。

To Reproduce Steps to reproduce the behavior:

➜  rax npm init rax demo
npx: 7 安装成功,用时 0.96 秒
Current registry:  https://registry.npm.taobao.org
npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
npm WARN deprecated request-promise@4.2.6: request-promise has been deprecated because it extends the now deprecated request package, see https://github.com/request/request/issues/3142
npm WARN deprecated har-validator@5.1.5: this
npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules
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!     /Users/Ken/.npm/_logs/2021-08-30T13_17_38_043Z-debug.log

Expected behavior It should create a new Rax project.

Screenshots As the code above.

(please complete the following information)

wjq990112 commented 3 years ago

这是你 npm 的权限问题,如果报这问题的话,我估计你全局安装其他包也有问题,网上有很多解决方法了,可以用 chmod 改一下文件夹的权限。 建议使用 homebrew 安装 nvm,然后通过 nvm 管理 node,这样不会出现 npm 的权限问题,或者使用 homebrew 直接安装 node 也行,如果直接使用 node 提供的安装包就会有这种情况。