简体   繁体   中英

problems with including dependencies in package.json

Why is it that when including dependencies in package.json such as

"dependencies": {
    "nodemailer": "*"
 }

and running

npm install

doesn't install the package but doing

npm install nodemailer

is ok?

in both instances, the message returned was

WARN Invalid name: "try node mailer"
WARN email No description
WARN email No repository field
WARN email No README field
WARN email No license field

but only in the second instance the node_modules directory is populated with the package

I'd suggest that you use some of the other version matching ranges and avoid the asterix one,, as per specs @page: https://docs.npmjs.com/files/package.json#dependencies

I did it fine with this one:

{
  "name": "test",
  "version": "1.0.0",
  "description": "my test",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "dependencies": {
    "nodemailer": "~2"
  },
  "author": "",
  "license": "ISC"
}

hope that helps you

Rather than using a wildcard, you can try "" instead. Otherwise this seems to be working:

{
  "name": "testr",
  "version": "1.0.0",
  "main": "main.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "dependencies": {
    "nodemailer": "^4.0.1"
  },
  "author": "",
  "license": "ISC"
}

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