简体   繁体   English

终端中的npm错误和警告

[英]npm errors and warnings in terminal

can anybody tells me what are those errors about and how to fix them? 谁能告诉我这些错误是什么以及如何解决这些错误? Everytime i try to install something in node with npm these errors show up in terminal enter image description here 每次我尝试在带有npm的节点中安装某些东西时,这些错误都会显示在终端上,在此处输入图像描述

The error you are facing is because you do not have package.json file. 您面临的错误是因为您没有package.json文件。 Npm installs the package in a node_modules/ subfolder, but warns you that there is no package.json file. Npm将软件包安装在node_modules /子文件夹中,但警告您没有package.json文件。 If you want to manage localy installed npm packages you should create a package.json file. 如果要管理本地安装的npm软件包,则应创建一个package.json文件。 Start by creating an empty folder: 首先创建一个空文件夹:

$ mkdir myapp
$ cd myapp

and then create a new package.json executing 然后创建一个新的package.json执行

$ npm init

Answer (or skip) all questions and at the end a brand new package.json will be created. 回答(或跳过)所有问题,最后将创建一个全新的package.json。

You can get more information from the Getting started articles in npm documentation: Working with package.json 您可以从npm文档中的入门文章中获取更多信息: 使用package.json

ENOENT stands for basically "Error, No Entry". ENOENT基本上表示“错误,无条目”。 this means it was looking for the package.json file and it couldn't find it.The fields mentioned below are also not found because they are a part of the package.json file 这意味着它正在寻找package.json文件,但找不到它。下面提到的字段也未找到,因为它们是package.json文件的一部分

so create a package.json file in the current current directory using 因此,使用以下命令在当前当前目录中创建一个package.json文件

npm init

and add the required content in the required fields i would also recommend you to install the modules locally into the directory of the particular project using 并在必填字段中添加必填内容,我也建议您使用以下命令将模块本地安装到特定项目的目录中

npm install express --save 

Hope my answer helps, cheers 希望我的回答有帮助,欢呼

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM