简体   繁体   中英

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

It looks like you are using the Cmder cmd prompt which is for Windows. If you are on Windows, then the n node version control does not support it. Here is their documentation that specifies that: https://github.com/tj/n

If you have NPM installed chances are you already have Node.js installed as well. You can check by typing: 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/

Also, you will want to set up a package.json file by running npm init in your cmd prompt. 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. Look in that package file and you will see Express listed as a dependency :)

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:

  • npm i -S package name (saves to your core dependencies)
  • npm i -D package name (saves to your dev dependencies)
  • npm i -g package name (saves globally)

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.

Hope that helps :)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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