npm WARN saveError ENOENT: no such file or directory, open 'C:\Users\Administrator\package.j

 

C:\Users\Administrator>npm install axios
npm WARN saveError ENOENT: no such file or directory, open 'C:\Users\Administrator\package.json'
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN enoent ENOENT: no such file or directory, open 'C:\Users\Administrator\package.json'
npm WARN Administrator No description
npm WARN Administrator No repository field.
npm WARN Administrator No README data
npm WARN Administrator No license field.

+ axios@0.24.0
added 2 packages from 4 contributors and audited 2 packages in 2.082s
found 0 vulnerabilities

 

原因:

根据错误提示,是系统没有‘package.json’这个文件导致。这个文件的作用就是管理本地安装的npm包。

 

解决方法:

方法一:

执行 npm init 命令,然后按Ctrl+C退出

npm init

方法二:

创建package.json文件,系统会提示相关配置,也可以使用命令:

npm init -y

 

执行完命令后可以看到用户路径下多了一个package.json文件。

C:\Users\Administrator>dir pa*
 Volume in drive C has no label.
 Volume Serial Number is BC50-BB3A

 Directory of C:\Users\Administrator

12/27/2021  08:36 AM               649 package-lock.json
               1 File(s)            649 bytes
               0 Dir(s)  24,383,279,104 bytes free

 

C:\Users\Administrator>dir pa*
 Volume in drive C has no label.
 Volume Serial Number is BC50-BB3A

 Directory of C:\Users\Administrator

12/27/2021  08:36 AM               649 package-lock.json
12/27/2021  08:52 AM               300 package.json
               2 File(s)            949 bytes
               0 Dir(s)  24,378,900,480 bytes free

 

上一篇:Java入门笔记 03-面向对象(下)


下一篇:【无标题】