在过去的几个月里,我每天都在使用nodejs和'Jenkins'。无需对我的 package.json 进行任何更改。在"jenkins"构建我的项目时,我收到以下错误 -
gifsicle@3.0.4 postinstall /var/lib/jenkins/workspace/musichords/public/node_modules/grunt-contrib-imagemin/node_modules/imagemin/node_modules/imagemin-gifsicle/node_modules/gifsicle
> node lib/install.js
module.js:338
throw err;
^
Error: Cannot find module '@gulp-sourcemaps/map-sources'
at Function.Module._resolveFilename (module.js:336:15)
at Function.Module._load (module.js:278:25)
at Module.require (module.js:365:17)
at require (module.js:384:17)
at Object.<anonymous> (/var/lib/jenkins/workspace/musichords/public/node_modules/vinyl-fs/node_modules/gulp-sourcemaps/index.js:6:15)
at Module._compile (module.js:460:26)
at Object.Module._extensions..js (module.js:478:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Module.require (module.js:365:17)
npm WARN optional dep failed, continuing imagemin-optipng@4.3.0
npm WARN optional dep failed, continuing imagemin-jpegtran@4.3.2
npm ERR! Linux 3.16.0-4-amd64
npm ERR! argv "/var/lib/jenkins/tools/jenkins.plugins.nodejs.tools.NodeJSInstallation/NodeJS_0.12.9/bin/node" "/var/lib/jenkins/tools/jenkins.plugins.nodejs.tools.NodeJSInstallation/NodeJS_0.12.9/bin/npm" "install"
npm ERR! node v0.12.9
npm ERR! npm v2.14.9
npm ERR! code E403
npm ERR! user developers is not allowed to access package @gulp-sourcemaps/map-sources : @gulp-sourcemaps/map-sources
npm ERR!
我已经运行了 npm 更新,删除并重新安装了 npm,安装了"gulp-sourcemaps"和更多依赖项。似乎什么都不起作用。
我在"包.json"的依赖项-
"dependencies": {
"acorn": "^5.0.0",
"async": "^1.5.1",
"aws-sdk": "^2.2.26",
"blueimp-md5": "^2.1.0",
"bytes": "^2.2.0",
"cheerio": "^0.20.0",
"collections": "^3.0.0",
"convert-source-map": "^1.5.0",
"cors": "^2.7.1",
"csv": "^0.4.6",
"css": "^2.2.1",
"extend": "^3.0.0",
"detect-newline": "^2.1.0",
"debug-fabulous": "^0.0.4",
"geoip-lite-youtab": "*",
"glob": "^7.0.0",
"grunt-contrib-imagemin": "^1.0.1",
"gulp": "^3.9.1",
"gulp-sourcemap": "^1.0.1",
"imagemin": "^5.2.0",
"imagemin-gifsicle": "^5.0.0",
"imagemin-jpegtran":"^5.0.0",
"imagemin-optipng":"^5.0.0",
"jade": "^1.11.0",
"jstransformer-clean-css": "^1.1.0",
"jstransformer-uglify-js": "^1.1.1",
"jstransformer-verbatim": "1.0.0",
"lru-cache": "^4.0.0",
"moment": "^2.11.0",
"needle": "^1.0.0",
"neo4j": "2.0.0-RC2",
"newrelic": "^1.24.1",
"node-genres": "*",
"optipng-bin": "^3.1.2",
"paypal-rest-sdk": "^1.7.1",
"source-map": "^0.5.6",
"string": "^3.3.1",
"text-encoding": "^0.6.1",
"underscore": "^1.8.3",
"underscore.string": "^3.2.2",
"winston": "^2.1.1",
"ytf-node-framework": "*",
"ytf-server": "*",
"ytf-server-commons": "*"
},
"devDependencies": {
"chai": "^3.4.1",
"grunt": "^0.4.5",
"grunt-contrib-clean": "~1.0.0",
"grunt-contrib-copy": "~0.8.2",
"grunt-contrib-watch": "^0.6.1",
"grunt-shell": "^1.1.2",
"mocha": "^2.3.4",
"spec-xunit-file": "^0.0.1-3",
"superagent-no-cache": "^0.1.0",
"supertest": "^1.1.0",
"tizi": "*"
}
感谢我能找到的任何帮助。
我能够通过将该范围的注册表显式设置为 npmjs 注册表来解决此问题。
npm config set @gulp-sourcemaps:registry https://registry.npmjs.org/
https://docs.npmjs.com/misc/scope
我相信更新您的 .npmrc 文件以包含它也可以:
@gulp-sourcemaps:registry=https://registry.npmjs.org
我们在较旧的 npm 版本中也遇到了这个问题,但即使升级到 4.4.4 也无济于事。 删除^对我们有用。
今天早上我在自己的构建中遇到了同样的问题。看来gulp-sourcemaps
的作者在两天前在其package.json
中添加了一个作用域依赖项。我不熟悉作用域依赖项,但似乎这就是导致npm install
失败的原因。我使用的是不支持作用域依赖项的较旧版本的 npm,但看起来您使用的是较新版本 - 可能是他们尚未发布依赖项,或者将其设置为公共,因为作用域依赖项默认为私有。
作为短期修复,您可以像我一样做,并从版本说明符中删除^
,以便在您自己的package.json
中gulp-sourcemaps
,这将避免拉取具有新作用域依赖项的最新版本gulp-sourcemaps
。