最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - npm start throwing error 'This is related to npm not being able to find a file.' - Stack Overflow

programmeradmin3浏览0评论

I just created a react app, it was working fine but once I restart the editor it is throwing error like this :

        Poojas-MacBook-Air:newreact pooja$ npm start
        npm ERR! path /Users/pooja/Desktop/projects/newreact/package.json
        npm ERR! code ENOENT
        npm ERR! errno -2
        npm ERR! syscall open
        npm ERR! enoent ENOENT: no such file or directory, open 
        '/Users/pooja/Desktop/projects/newreact/package.json'
        npm ERR! enoent This is related to npm not being able to find a file.
        npm ERR! enoent 

        npm ERR! A plete log of this run can be found in:
        npm ERR!     /Users/pooja/.npm/_logs/2020-11-28T10_27_42_118Z-debug.log

Please help if anyone knows about it.

I just created a react app, it was working fine but once I restart the editor it is throwing error like this :

        Poojas-MacBook-Air:newreact pooja$ npm start
        npm ERR! path /Users/pooja/Desktop/projects/newreact/package.json
        npm ERR! code ENOENT
        npm ERR! errno -2
        npm ERR! syscall open
        npm ERR! enoent ENOENT: no such file or directory, open 
        '/Users/pooja/Desktop/projects/newreact/package.json'
        npm ERR! enoent This is related to npm not being able to find a file.
        npm ERR! enoent 

        npm ERR! A plete log of this run can be found in:
        npm ERR!     /Users/pooja/.npm/_logs/2020-11-28T10_27_42_118Z-debug.log

Please help if anyone knows about it.

Share Improve this question asked Nov 28, 2020 at 10:37 Pooja KushwahPooja Kushwah 1872 gold badges2 silver badges14 bronze badges 3
  • are you in the file diretry. it is showing package.json is not in the current directry. – sharun k k Commented Nov 28, 2020 at 10:39
  • yes in a same directory – Pooja Kushwah Commented Nov 28, 2020 at 10:40
  • 1 please share your directry file list in the question. – sharun k k Commented Nov 28, 2020 at 10:42
Add a ment  | 

4 Answers 4

Reset to default 4
  1. Make sure you have the latest npm (npm install -g npm).
  2. Add an exception to your antivirus to ignore the node_modules folder in your project.
  3. rm -rf node_modules package-lock.json
  4. npm install

Sometimes the PATH is not correct, just open the cmd and cd to the address where the package.json is and then run npm start

For me, it was because of the running Metro server. If anyone is experiencing this issue in react-native, make sure you have stopped the running Metro server instance before entering npm i <package-name>.
With yarn, I think, there's no such issue.

To resolve package.json file, go to your project folder and find package.json location folder. Open terminal and make sure your are in correct path where package.json file located. eg: c://projectfolder/folder1/clientapp> npm start

发布评论

评论列表(0)

  1. 暂无评论