简体   繁体   English

无法安装快递和包裹

[英]Can't install express and packages

在此处输入图片说明

在此处输入图片说明

Hey, excuse me if this question is ridiculous but I can't handle with start in nodeJS, I try to install npm install -gn global and try install express locally but I cannot do this, I am trying install express like that npm install express before set my local path 嘿,对不起,如果这个问题很可笑,但是我无法在nodeJS中使用start进行处理,我尝试安装npm install -gn global并尝试在本地安装express,但是我无法做到这一点,我正在尝试像那npm install express一样npm install express在设置我的本地路径之前

It looks like you are using the Cmder cmd prompt which is for Windows. 看起来您正在使用Windows的Cmder cmd提示符。 If you are on Windows, then the n node version control does not support it. 如果在Windows上,则n节点版本控件不支持它。 Here is their documentation that specifies that: https://github.com/tj/n 这是他们的文档,该文档指定了以下内容: https : //github.com/tj/n

If you have NPM installed chances are you already have Node.js installed as well. 如果您有安装NPM的机会, 那么您也已经安装了Node.js。 You can check by typing: node -v . 您可以输入以下命令进行检查: node -v

If you do not see a version # like v7.0.0 after typing that, go to this page to download Node.js: https://nodejs.org/en/download/ 如果输入后没有看到类似v7.0.0的版本号,请转到此页面下载Node.js: https : //nodejs.org/en/download/

Also, you will want to set up a package.json file by running npm init in your cmd prompt. 另外,您将要通过在cmd提示符下运行npm init来设置package.json文件 Try running the same command you used to install express and then check the directory you installed it into, and you should see a package.json file. 尝试运行与安装express相同的命令,然后检查将其安装到的目录,您应该会看到package.json文件。 Look in that package file and you will see Express listed as a dependency :) 查看该软件包文件,您将看到Express作为依赖项列出:)

Here are a few ways you can install packages. 您可以通过以下几种方式安装软件包。 Go to the base of your project directory where your package.json file is located and try: 转到package.json文件所在的项目目录的底部,然后尝试:

  • npm i -S package name (saves to your core dependencies) npm i -S package name (保存到您的核心依赖项)
  • npm i -D package name (saves to your dev dependencies) npm i -D package name (保存到您的dev依赖项中)
  • npm i -g package name (saves globally) npm i -g package name (全局保存)

Core dependencies are for packages that you want to use in production whereas dev dependencies are good for things like testing suites and build tools. 核心依存关系用于您要在生产中使用的软件包,而开发依存关系则对测试套件和构建工具之类的东西有好处。 Saving globally is good when you want access the package's CLI from any directory in your command prompt. 当您想从命令提示符下的任何目录访问程序包的CLI时,最好进行全局保存

Hope that helps :) 希望有帮助:)

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

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