运行npm install

时间:2018-06-13 00:03:35

标签: git npm

运行npm install时出现以下错误:

npm ERR! code 1
npm ERR! Command failed: /usr/bin/git checkout ~3.9.0
npm ERR! error: pathspec '~3.9.0' did not match any file(s) known to git.
npm ERR!

node和npm版本:

$ node -v
v10.4.0

$ npm -v
6.1.0

我尝试降级npm并在两台不同的机器上运行它,但结果相同。

以下是package.json中的依赖项:

"dependencies": {
"@bower_components/jquery": "jquery/jquery-dist#3.3.1",
"@bower_components/lodash": "lodash/lodash#~3.9.0",
"autosize": "^4.0.2",
"babel-core": "^6.26.3",
"babel-jest": "^23.0.1",
"babel-loader": "^7.1.4",
"babel-plugin-add-module-exports": "^0.2.1",
"babel-plugin-rewire": "^1.0.0",
"babel-plugin-transform-object-rest-spread": "^6.26.0",
"babel-polyfill": "^6.26.0",
"babel-preset-es2015": "^6.24.1",
"babel-preset-react": "^6.24.1",
"chai": "^4.1.2",
"chart.js": "^2.7.2",
"chartkick": "^2.3.5",
"chosen-js": "^1.8.5",
"core-js": "^2.5.7",
"create-react-class": "^15.6.3",
"del": "^3.0.0",
"enzyme": "^3.3.0",
"enzyme-adapter-react-15": "^1.0.2",
"eslint": "^4.19.1",
"eslint-config-airbnb": "^16.1.0",
"eslint-plugin-import": "^2.12.0",
"eslint-plugin-jsx-a11y": "^6.0.3",
"eslint-plugin-react": "^7.8.2",
"event-stream": "^3.3.4",
"gulp": "^3.8.7",
"gulp-autoprefixer": "^4.0.0",
"gulp-cached": "^1.1.1",
"gulp-clean": "^0.3.0",
},
 "scripts": {
"test": "jest",
"start": "gulp dev",
"hot": "gulp hot-dev",
"build": "gulp build"
}

2 个答案:

答案 0 :(得分:19)

对我来说4.0出现相同问题 我在package.json中有一个依赖项 “ gulp”:“ github:gulpjs / gulp#4.0”,

我删除了#4.0及其现在的文件。

答案 1 :(得分:1)

我来晚了,但是我的回答可能会向这里的所有访客澄清这个问题。

Git无法使用3.9.0版本的“指定路径”解析依赖项。删除版本3.9.0将选择可用的最新版本。正如此处答案之一所提到的,吞咽不一定是问题。我在您的 package.json 中的@bower_components/lodash": "lodash/lodash#~3.9.0"中看到了该版本。因此,删除#~3.9.0应该可以。