Solving the 'npm WARN saveError ENOENT: no such file or directory, open '/Users//package.json'' error

前端 未结 7 1371
半阙折子戏
半阙折子戏 2020-12-17 08:15

I\'m a newbie so please include links to URLs or explain terminologies so I can understand.

I\'ve managed to install \'npm\' on a Mac OS (10.13.3) via the

7条回答
  •  爱一瞬间的悲伤
    2020-12-17 08:41

    Issue:

    npm install fails with below error
    npm WARN saveError ENOENT: no such file or directory, open '.../package.json'' error

    Cause

    npm install will need package.json in the current directory you are in, which is missing.

    Solution

    Assume there are 2 directories:

    C:\dir1_p\       <--------- package.json exists
    C:\dir2\         <--------- package.json does not exist
    
    cd C:\dir1_p\
    npm intall      <---------- PASS, since package.json is present
    
    cd C:\dir2\
    npm intall      <---------- ERROR, since package.json is Not present  (this was my problem)
    

    So, are you in the correct directory when you did npm install?

    Case 1: if you are in wrong directory, cd to a directory where package.json exists, then run npm install

    Case 2: if you are in correct directory, then run npm init and press ENTER keys until it is completed, this will create package.json in current directory, now run npm install

    Hope this helps someone.

提交回复
热议问题