npm init 不会创建 package.json 文件
npm init will not create package.json file
test 目录为空,运行 npm init 未创建 package.json 文件。
下面的错误说没有这样的目录,这很令人困惑,因为当 运行 npm init 命令时我在所说的目录中。
PS C:\Users\Sayee\OneDrive\Documents\test> 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:\Users\Sayee\OneDrive\Documents\test\package.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:\Users\Sayee\OneDrive\Documents\test\package.json
npm ERR! errno -4058
npm ERR! enoent ENOENT: no such file or directory, open 'C:\Users\Sayee\OneDrive\Documents\test\package.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:\Users\Sayee\AppData\Local\npm-cache\_logs21-09-01T19_50_44_400Z-debug.log
版本:
node v15.5.1
npm v7.4.2
编辑:
如果我在目录中手动创建一个空 package.json 文件,则会出现不同的错误。 Package.json 文件无法在任何地方打开,我已经尝试 运行 终端作为管理员。
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:\Users\Sayee\AppData\Local\npm-cache\_logs21-09-01T23_57_39_015Z-debug.log
我认为这个问题与 npm/node 无关,可能是由于 C:\Users\Sayee\OneDrive\Documents\
.
的特殊文件系统 ownership/permission
在勒索软件保护下的 windows 中禁用 受控文件夹访问 解决了这个问题。
test 目录为空,运行 npm init 未创建 package.json 文件。
下面的错误说没有这样的目录,这很令人困惑,因为当 运行 npm init 命令时我在所说的目录中。
PS C:\Users\Sayee\OneDrive\Documents\test> 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:\Users\Sayee\OneDrive\Documents\test\package.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:\Users\Sayee\OneDrive\Documents\test\package.json
npm ERR! errno -4058
npm ERR! enoent ENOENT: no such file or directory, open 'C:\Users\Sayee\OneDrive\Documents\test\package.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:\Users\Sayee\AppData\Local\npm-cache\_logs21-09-01T19_50_44_400Z-debug.log
版本:
node v15.5.1
npm v7.4.2
编辑:
如果我在目录中手动创建一个空 package.json 文件,则会出现不同的错误。 Package.json 文件无法在任何地方打开,我已经尝试 运行 终端作为管理员。
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:\Users\Sayee\AppData\Local\npm-cache\_logs21-09-01T23_57_39_015Z-debug.log
我认为这个问题与 npm/node 无关,可能是由于 C:\Users\Sayee\OneDrive\Documents\
.
在勒索软件保护下的 windows 中禁用 受控文件夹访问 解决了这个问题。