我在 Linux 上安装了 Node v 18。
如果我在我的主目录中尝试这些命令一切正常:
npm create svelte@latest my-app cd my-app npm install
svelte 已安装。
当我在主目录之外尝试相同的命令时,即在 /media/web/www 中,我在 npm install 时收到此错误:
npm ERR! code 1
pnpm ERR! path /media/web/www/my-app/node_modules/esbuild
npm ERR! command failed
npm ERR! command sh -c -- node install.js
npm ERR! node:internal/errors:491
npm ERR! ErrorCaptureStackTrace(err);
npm ERR! ^
npm ERR!
npm ERR! <ref *1> Error: spawnSync /media/web/www/my-app/node_modules/esbuild/bin/esbuild EACCES
npm ERR! at Object.spawnSync (node:internal/child_process:1110:20)
npm ERR! at spawnSync (node:child_process:871:24)
npm ERR! at Object.execFileSync (node:child_process:914:15)
npm ERR! at validateBinaryVersion (/media/web/www/my-app/node_modules/esbuild/install.js:96:28)
npm ERR! at /media/web/www/my-app/node_modules/esbuild/install.js:283:5 {
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'spawnSync /media/web/www/my-app/node_modules/esbuild/bin/esbuild',
npm ERR! path: '/media/web/www/my-app/node_modules/esbuild/bin/esbuild',
npm ERR! spawnargs: [ '--version' ],
npm ERR! error: [Circular *1],
npm ERR! status: null,
npm ERR! signal: null,
npm ERR! output: null,
npm ERR! pid: 0,
npm ERR! stdout: null,
npm ERR! stderr: null
npm ERR! }
npm ERR!
npm ERR! Node.js v18.13.0
为什么?我真的不明白。
这是我的配置的一部分:
prefix = "/usr"
全局模块位于:
/usr/lib/node_modules
当尝试 npm start 时,与 /media/web/www 中的反应相同:
sh: /media/web/www/app-name/node_modules/.bin/react-scripts: Permission denied
终于找到解决我的问题的方法了。
我的主目录之外的分区已作为用户安装,用户权限。这就是许可被拒绝的原因。使用“默认值”代替
您能详细描述一下这个问题的解决方案吗?