npm init doesn't work, ENOENT: no such file or directory

491 Views Asked by At

I install node 14(LTS) on my window10, and npm is auto install, but npm init isn't work.

I check version of them is work

C:\Users\RURU\Documents\practice\css> node -v
// 14.4
C:\Users\RURU\Documents\practice\css> npm -v
// 6

but, npm init does't work, when I want to init a package.json.

C:\Users\RURU\Documents\practice\css> npm init # neither npm init -y

Error :

npm ERR! code ENOENT
npm ERR! syscall open
npm ERR! path C:\Users\RURU\Documents\practice\css\package.json
npm ERR! errno -4058
npm ERR! enoent ENOENT: no such file or directory, open 'C:\Users\RURU\Documents\practice\css\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\RURU\AppData\Local\npm-cache\_logs\2021-07-04T14_37_28_289Z-debug.log

Error log:

0 info it worked if it ends with ok
1 verbose cli [
1 verbose cli   'C:\\Program Files\\nodejs\\node.exe',
1 verbose cli   'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli   'init'
1 verbose cli ]
2 info using [email protected]
3 info using [email protected]
4 silly package data {
4 silly package data   name: 'c',
4 silly package data   version: '1.0.0',
4 silly package data   description: '',
4 silly package data   main: 'index.js',
4 silly package data   scripts: { test: 'echo "Error: no test specified" && exit 1' },
4 silly package data   author: 'ru',
4 silly package data   license: 'ISC'
4 silly package data }
5 info init written successfully
6 verbose stack Error: ENOENT: no such file or directory, open 'C:\Users\RURU\Documents\practice\css\package.json'
7 verbose cwd C:\Users\RURU\Documents\practice\css
8 verbose Windows_NT 10.0.19042
9 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "init"
10 verbose node v14.17.2
11 verbose npm  v6.14.13
12 error code ENOENT
13 error syscall open
14 error path C:\Users\RURU\Documents\practice\css\package.json
15 error errno -4058
16 error enoent ENOENT: no such file or directory, open 'C:\Users\RURU\Documents\practice\css\package.json'
17 error enoent This is related to npm not being able to find a file.
18 verbose exit [ -4058, true ]

I dont't know how to fix it, can anyone help, please ...

my path

C:\Program Files\nodejs\;C:\Users\RURU\AppData\Roaming\npm
1

There are 1 best solutions below

0
On BEST ANSWER

You can use 2 things to solve the problem :

  1. Start the cmd in administrator mode and try again.
  2. Run the command using --unsafe-perms i.e. npm init --unsafe-perms

I don't think 2 step will be required in most of the cases.