首页 > 解决方案 > npm install 不会创建 node_modules 文件夹

问题描述

我正在尝试使用 Typescript 遵循 Protractor 的官方教程

这是我的package.json

{
  "name": "typescript-exercise",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC",
"dependencies": {
  "@types/jasmine": "~3.5.7",
  "@types/jasminewd2": "~2.0.8",
  "jasmine": "~3.5.0",
  "protractor": "~5.4.3",
  "typescript": "~3.8.3",
  "ts-node": "~8.6.2",
  "@types/node":"~13.7.7"
 }

}

当我运行 npm install 我得到以下结果:

npm WARN typescript-exercise@1.0.0 No description
npm WARN typescript-exercise@1.0.0 No repository field.

up to date in 0.527s
found 0 vulnerabilities

但是,我的根目录中没有node_mdules文件夹。

为什么 npm install 不能建 node_modules

标签: node.js

解决方案


出现错误时,请尝试从您的 : 中删除空标签package.json

{
  "name": "typescript-exercise",
  "version": "1.0.0",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "license": "ISC",
  "dependencies": {
    "@types/jasmine": "~3.5.7",
    "@types/jasminewd2": "~2.0.8",
    "jasmine": "~3.5.0",
    "protractor": "~5.4.3",
    "typescript": "~3.8.3",
    "ts-node": "~8.6.2",
    "@types/node":"~13.7.7"
  }
}

如果您package-lock.json尝试删除它然后运行npm i​​. 希望这对你有用。


推荐阅读