错误:找不到模块'iconv-lite'

时间:2016-05-24 14:37:27

标签: node.js jenkins gruntjs

我正在尝试在 Jenkins 中运行 nodejs 脚本,但是当我触发构建时,我得到了这个错误:找不到模块'iconv-lite “

所以为了防止这种情况我也尝试安装模块“npm install iconv-lite --save-dev” 但我仍面临同样的问题。

我的作业配置包括一个shell脚本,后跟一个nodejs脚本。

Shell脚本数据:

npm install grunt-contrib-watch --save-dev
npm install grunt-contrib-copy --save-dev
npm install grunt-contrib-uglify --save-dev
npm install grunt-contrib-requirejs --save-dev
npm install grunt-connect-proxy --save-dev
npm install iconv-lite --save-dev

这是控制台输出

[test_js] $ /bin/sh -xe /tmp/hudson3463493438343490126.sh
+ npm install grunt-connect-proxy --save-dev
grunt-connect-proxy@0.2.0 node_modules/grunt-connect-proxy
├── lodash@0.9.2
└── http-proxy@1.11.3 (eventemitter3@1.2.0, requires-port@0.0.1)
+ npm install grunt-contrib-watch --save-dev
grunt-contrib-watch@1.0.0 node_modules/grunt-contrib-watch
├── async@1.5.2
├── gaze@1.0.0 (globule@0.2.0)
├── lodash@3.10.1
└── tiny-lr@0.2.1 (parseurl@1.3.1, livereload-js@2.2.2, qs@5.1.0, debug@2.2.0, faye-websocket@0.10.0, body-parser@1.14.2)
+ npm install grunt-contrib-copy --save-dev
grunt-contrib-copy@1.0.0 node_modules/grunt-contrib-copy
├── file-sync-cmp@0.1.1
└── chalk@1.1.3 (escape-string-regexp@1.0.5, ansi-styles@2.2.1, supports-color@2.0.0, strip-ansi@3.0.1, has-ansi@2.0.0)
+ npm install grunt-contrib-uglify --save-dev
grunt-contrib-uglify@1.0.1 node_modules/grunt-contrib-uglify
├── uri-path@1.0.0
├── chalk@1.1.3 (escape-string-regexp@1.0.5, supports-color@2.0.0, ansi-styles@2.2.1, has-ansi@2.0.0, strip-ansi@3.0.1)
├── uglify-js@2.6.2 (uglify-to-browserify@1.0.2, async@0.2.10, source-map@0.5.6, yargs@3.10.0)
├── maxmin@1.1.0 (figures@1.7.0, gzip-size@1.0.0, pretty-bytes@1.0.4)
└── lodash@4.13.1
+ npm install grunt-contrib-requirejs --save-dev
grunt-contrib-requirejs@1.0.0 node_modules/grunt-contrib-requirejs
└── requirejs@2.2.0
+ npm install iconv-lite --save-dev
iconv-lite@0.4.13 node_modules/iconv-lite
[test_js] $ /usr/local/bin/node /tmp/hudson7464326776362659565.js
module.js:338
    throw err;
          ^
Error: Cannot find module 'iconv-lite'
    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> (/tmp/hudson402761881726281197.js:5:13)
    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 Function.Module.runMain (module.js:501:10)
Build step 'Execute NodeJS script' marked build as failure
Finished: FAILURE

在大多数此类问题中,我发现解决方案是使用“npm install module-name”, 我已经尝试在我的linux机器上安装,并且通过在作业配置的shell脚本中提供它,但在这种情况下它无法正常工作。

当我尝试使用“npm install module_name -g --save-dev”

全局安装它时
# npm install grunt-connect-proxy -g --save-dev
npm WARN unmet dependency /usr/local/lib/node_modules/grunt requires grunt-    cli@'~1.2.0' but will load
npm WARN unmet dependency /usr/local/lib/node_modules/grunt-cli,
npm WARN unmet dependency which is version 0.1.8
npm ERR! Linux 2.6.32-358.23.2.el6.x86_64
npm ERR! argv "node" "/usr/local/bin/npm" "install" "grunt-connect-proxy" "-g" "--save-dev"
npm ERR! node v0.12.4
npm ERR! npm  v2.0.0
npm ERR! code EPEERINVALID

npm ERR! peerinvalid The package grunt does not satisfy its siblings' peerDependencies requirements!
npm ERR! peerinvalid Peer grunt-connect-proxy@0.2.0 wants grunt@~0.4.1

npm ERR! Please include the following file with any support request:
npm ERR!     /home/jenkins/npm-debug.log

和grunt-version是

# grunt --version
grunt-cli v0.1.8
grunt v0.4.5

可能的原因是什么?

提前致谢!

0 个答案:

没有答案