为什么在package.json中包含依赖项时如
"dependencies": {
"nodemailer": "*"
}
并正在运行
npm install
不安装软件包,而是执行
npm install nodemailer
好吗?
在两个实例中,返回的消息是
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
但仅在第二个实例中,node_modules目录使用包
填充答案 0 :(得分:2)
我建议您使用其他一些版本匹配范围并避免使用asterix,根据规格@page:https://docs.npmjs.com/files/package.json#dependencies
我用这个做得很好:
{
"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"
}
希望能帮到你
答案 1 :(得分:1)
您可以尝试""
而不是使用通配符。否则这似乎有效:
{
"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"
}