简体   繁体   English

什么是 npm 命令以及如何使用它?

[英]What is npm command and how to use it?

What is npm?什么是 npm?

Whenever I browse through some project they ask me to run npm command, something like this每当我浏览某个项目时,他们要求我运行 npm 命令,类似这样

npm install -g node-windows

I went through some blogs to learn about npm and I installed node.js, however when I run the above code in node.js, I get the following errors:我浏览了一些博客来了解 npm 并安装了 node.js,但是当我在 node.js 中运行上述代码时,出现以下错误:

在此处输入图像描述

When I browsed further, I came to know that the windows user can run the command from the cmd prompt window, but when I do that I get some output like this:当我进一步浏览时,我知道 windows 用户可以从 cmd 提示符窗口运行命令,但是当我这样做时,我会得到如下输出:

在此处输入图像描述

Which just generate a text file nothing else.这只是生成一个文本文件而已。

So my question are:所以我的问题是:

  1. How to get started with the AngularJS2 ?如何开始使用AngularJS2
  2. How to run a npm command?如何运行 npm 命令?
  3. Does I require command prompt to run npm command(in windows), or I can just use Node.js ?我是否需要命令提示符来运行 npm 命令(在 Windows 中),或者我可以只使用Node.js

UPDATE 1更新 1

When I use the command npm install in my command prompt, I get the following output:当我在命令提示符中使用命令 npm install 时,我得到以下输出:

在此处输入图像描述

  1. How to get started with the angularJS2如何开始使用 angularJS2

    Follow this link and setup the project by following instructions按照链接并按照说明设置项目

  2. How to run a npm command如何运行 npm 命令

    npm stands for Node Package Manager, therefore you need NodeJS installed before you can run npm commands. npm 代表 Node Package Manager,因此您需要先安装 NodeJS,然后才能运行 npm 命令。

    Follow this and install the latest version.按照操作并安装最新版本。 And restart the command prompt.并重新启动命令提示符。

  3. Do I require command prompt to run npm command(in windows), or i can just use node.js我是否需要命令提示符来运行 npm 命令(在 Windows 中),或者我可以只使用 node.js

    Yes, you need to run npm commands from the command(in windows).是的,您需要从命令(在 Windows 中)运行 npm 命令。

    eg npm install例如 npm 安装

You get the warning because there is no package.json file present where you are running the command.您收到警告是因为在您运行命令的位置不存在 package.json 文件。 ENOENT stands for Error NO ENTrey ENOENT代表错误 NO ENTrey

Navigate to the project folder using the following command and then run npm install使用以下命令导航到项目文件夹,然后运行 ​​npm install

cd <projectpath>

AngularJS 2 website has everything you need covered. AngularJS 2 网站涵盖了您需要的一切。 Their quickstart guide alongside with the quickseed zip file help a lot.他们的快速入门指南以及快速种子zip 文件有很大帮助。

But, in case you missed some points:但是,如果您错过了一些要点:

  • yes, you will need npm/NodeJS.是的,你需要npm/NodeJS。 So, download the latest distribution and have a clean installation of it.因此,下载最新的发行版并进行全新安装。

  • you can execute the npm command with its parameters from withing the windows cmd.您可以使用 windows cmd 的参数执行npm命令。

  • the quickseed zip contains all the files you need to see a live and quick example running locally. quickseed zip 包含查看本地运行的实时快速示例所需的所有文件。 Unzip it on your workplace and navigate to it using the windows cmd.在您的工作场所解压缩使用 windows cmd 导航到它。 When inside the root folder of the unzipped package, execute npm install and right after it npm start .在解压缩包的文件夹中,执行npm install并紧随其后npm start

Take the learning path .学习之路 Step by step all your questions will be answered一步一步你所有的问题都会得到解答

您需要使用管理员提示符进行全局安装( -g

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

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