NPM init不会创建包.json文件



test目录是空的,运行NPM init不会创建一个包。json文件。

下面的错误说没有这样的目录,这让人困惑,因为我在运行npm init命令时在该目录中。

PS C:UsersSayeeOneDriveDocumentstest> npm init
Press ^C at any time to quit.
package name: (test)
version: (1.0.0)
description:
entry point: (index.js)
test command:
git repository:
keywords:
author:
license: (ISC)
About to write to C:UsersSayeeOneDriveDocumentstestpackage.json:
{
"name": "test",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo "Error: no test specified" && exit 1"
},
"author": "",
"license": "ISC"
}

Is this OK? (yes)
npm ERR! code ENOENT
npm ERR! syscall open
npm ERR! path C:UsersSayeeOneDriveDocumentstestpackage.json
npm ERR! errno -4058
npm ERR! enoent ENOENT: no such file or directory, open 'C:UsersSayeeOneDriveDocumentstestpackage.json'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent
npm ERR! A complete log of this run can be found in:
npm ERR!     C:UsersSayeeAppDataLocalnpm-cache_logs2021-09-01T19_50_44_400Z-debug.log

版本:

  • 节点v15.5.1

  • npm v7.4.2

编辑:

不同的错误,如果我手动创建一个空包。目录下的Json文件。包中。json文件在任何地方都没有打开,我试过以admin身份运行终端。

npm ERR! code EPERM
npm ERR! syscall write
npm ERR! errno -4048
npm ERR! Error: EPERM: operation not permitted, write
npm ERR!  [Error: EPERM: operation not permitted, write] {
npm ERR!   errno: -4048,
npm ERR!   code: 'EPERM',
npm ERR!   syscall: 'write'
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:UsersSayeeAppDataLocalnpm-cache_logs2021-09-01T23_57_39_015Z-debug.log

我认为这个问题与npm/node无关,可能是由于C:UsersSayeeOneDriveDocuments的特殊文件系统所有权/权限。

禁用受控文件夹访问在勒索软件保护下的windows中修复了此问题。

最新更新