甚至我尝试了设置执行策略为无限制,这解决了我的虚拟服务错误,但无法创建package.json。
输出粘贴在下面。请注意:我同时尝试了npm init和npm init -y
PS C:\Windows\System32\WindowsPowerShell\v1.0> npm init -y
npm ERR! code EPERM
npm ERR! syscall open
npm ERR! path C:\Windows\System32\WindowsPowerShell\v1.0\package.json
npm ERR! errno -4048
npm ERR! Error: EPERM: operation not permitted, open 'C:\Windows\System32\WindowsPowerShell\v1.0\package.json'
npm ERR! [Error: EPERM: operation not permitted, open 'C:\Windows\System32\WindowsPowerShell\v1.0\package.json'] {
npm ERR! errno: -4048,
npm ERR! code: 'EPERM',
npm ERR! syscall: 'open',
npm ERR! path: 'C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\package.json'
npm ERR! }
npm ERR!
npm ERR! The operation was rejected by your operating system.
npm ERR! It's possible that the file was already in use (by a text editor or antivirus),
npm ERR! or that you lack permissions to access it.
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! C:\Users\User\AppData\Roaming\npm-cache\_logs\2020-06-14T08_03_04_050Z-debug.log发布于 2020-06-14 16:35:14
您不能创建package.json,因为您处于C:\Windows\System32下。Windows正在阻止您创建自己的保存系统文件的文件。
切换到另一个目录(最好是C:\Users\YourUsernameHere\下的目录),然后重试。
https://stackoverflow.com/questions/62370053
复制相似问题