今天,当我尝试使用npm i安装所有软件包时,无论是否使用sudo命令,我都被拒绝了权限。使用sudo还会产生其他错误。我想昨晚调整和试验该应用程序时弄乱了权限。以前效果很好。我尝试根据先前类似问题发布的解决方案来更改权限,但是这些问题不起作用。
安装指定的软件包有效;仅当我尝试安装所有软件包时,命令才会中断。我使用--allow-root和--unsafe-perm = true作为使命令起作用的技巧,但是我希望有一个更安全,系统的解决方案。错误如下:
没有sudo:
npm WARN checkPermissions Missing write access to /home/user/project/node_modules
npm WARN tsutils@3.17.1 requires a peer of typescript@>=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta but none is installed. You must install peer dependencies yourself.
npm ERR! code EaccES
npm ERR! syscall access
npm ERR! path /home/user/project/node_modules
npm ERR! errno -13
npm ERR! Error: EaccES: permission denied,access '/home/user/project/node_modules'
npm ERR! [Error: EaccES: permission denied,access '/home/user/project/node_modules'] {
npm ERR! stack: "Error: EaccES: permission denied,access '/home/user/project/node_modules'",npm ERR! errno: -13,npm ERR! code: 'EaccES',npm ERR! syscall: 'access',npm ERR! path: '/home/user/project/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/user/.npm/_logs/2019-12-03T04_30_10_304Z-debug.log
使用sudo:
> node@8.10.0 preinstall /home/user/project/node_modules/node
> node installArchSpecificPackage
npm WARN checkPermissions Missing write access to /home/user/project/node_modules/node
npm ERR! code EaccES
npm ERR! syscall access
npm ERR! path /home/user/project/node_modules/node
npm ERR! errno -13
npm ERR! Error: EaccES: permission denied,access '/home/user/project/node_modules/node'
npm ERR! [Error: EaccES: permission denied,access '/home/user/project/node_modules/node'] {
npm ERR! stack: "Error: EaccES: permission denied,access '/home/user/project/node_modules/node'",npm ERR! path: '/home/user/project/node_modules/node'
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,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/user/.npm/_logs/2019-12-03T04_30_23_864Z-debug.log
internal/modules/cjs/loader.js:895
throw err;
^
Error: Cannot find module 'node-linux-x64/package.json'
Require stack:
- /home/user/project/node_modules/node/installArchSpecificPackage.js
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:892:15)
at Function.resolve (internal/modules/cjs/helpers.js:80:19)
at ChildProcess.<anonymous> (/home/user/project/node_modules/node-bin-setup/index.js:18:27)
at ChildProcess.emit (events.js:210:5)
at maybeclose (internal/child_process.js:1028:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:283:5) {
code: 'MODULE_NOT_FOUND',requireStack: [
'/home/user/project/node_modules/node/installArchSpecificPackage.js'
]
}
npm WARN tsutils@3.17.1 requires a peer of typescript@>=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta but none is installed. You must install peer dependencies yourself.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! node@8.10.0 preinstall: `node installArchSpecificPackage`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the node@8.10.0 preinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/user/.npm/_logs/2019-12-03T04_30_24_450Z-debug.log
是否有更好的方法来解决此问题而不依赖于不安全的perm参数?