2017-03-09 101 views
2

我用下面package.json在我的節點項目,當我運行 npm test,它給下面的錯誤npm,nodejs,package.json,模塊版本不匹配。預計48,51了

模塊版本不匹配。預計48,得到51

{ 
    "name": "f-api", 
    "version": "0.0.1", 
    "Description": "F", 
    "author": "F", 
    "private": true, 
    "scripts": { 
    "start": "node ./bin/www", 
    "start_supervise": "supervisor ./bin/www", 
    "test": "mocha --recursive --timeout 10000" 
    }, 
    "dependencies": { 
    "bcrypt": "=1.0.2", 
    "body-parser": "~1.13.2", 
    "config": "^1.24.0", 
    "cookie-parser": "~1.3.5", 
    "debug": "~2.2.0", 
    "express": "~4.13.1", 
    "jwt-simple": "^0.5.1", 
    "moment": "^2.17.1", 
    "morgan": "~1.6.1", 
    "nodemailer": "=2.7.2", 
    "nodemailer-smtp-transport": "^2.7.2", 
    "pg-promise": "^3.2.3", 
    "sequelize": "^3.29.0", 
    "sequelize-cli": "^2.1.0", 
    "supervisor": "^0.12.0" 
    }, 
    "devDependencies": { 
    "chai": "^3.5.0", 
    "chai-http": "^3.0.0", 
    "mocha": "^3.2.0", 
    "nodemailer-stub": "^1.0.1", 
    "should": "^11.1.2", 
    "supertest": "^2.0.1" 
    } 
} 

我認爲這是版本的一些不兼容的,我是有點新的node, npm和版本類似語法^, ~, =

我得到以下出來放在gitlab亞軍,搬運工遺囑執行人

Running with gitlab-ci-multi-runner 1.11.1 (a67a225) 
    on gitlab-runner-b-ubuntuvm (1ffe18b1) 
Using Docker executor with image node:6.10.0 ... 
Starting service postgres:latest ... 
Pulling docker image postgres:latest ... 
Waiting for services to be up and running... 
Pulling docker image node:6.10.0 ... 
Running on runner-1ffe18b1-project-6-concurrent-0 via ubuntu... 
Cloning repository... 
Cloning into '/builds/f/f-api'... 
Checking out bcf3e283 as development... 
Skipping Git submodules setup 
Downloading artifacts for build:linux (495)... 
Downloading artifacts from coordinator... ok  id=495 responseStatus=200 OK token=hXK-foh8 
Checking cache for test:linux/development... 
Successfully extracted cache 
$ ./node_modules/.bin/sequelize db:migrate --env=continuous_integration 

Sequelize [Node: 6.10.0, CLI: 2.5.1, ORM: 3.30.2] 

Loaded configuration file "config_tmp.json". 
== 20170120101655-createUserTable: migrating ======= 
== 20170120101655-createUserTable: migrated (0.031s) 
== 20170120111051-addPasswordDigestToUsers: migrating ======= 
== 20170120111051-addPasswordDigestToUsers: migrated (0.026s) 
== 20170226151953-update-users: migrating ======= 
== 20170226151953-update-users: migrated (0.047s) 
== 20170307043733-update-users2: migrating ======= 
== 20170307043733-update-users2: migrated (0.049s) 
== 20170308023252-create-profile: migrating ======= 
== 20170308023252-create-profile: migrated (0.027s) 
== 20170308055218-update-users3-link-profile: migrating ======= 
== 20170308055218-update-users3-link-profile: migrated (0.017s) 
$ npm test 
npm info it worked if it ends with ok 
npm info using [email protected] 
npm info using [email protected] 
npm info lifecycle [email protected]~pretest: [email protected] 
npm info lifecycle [email protected]~test: [email protected] 

> [email protected] test /builds/f/f-api 
> mocha --recursive --timeout 10000 

module.js:597 
    return process.dlopen(module, path._makeLong(filename)); 
       ^

Error: Module version mismatch. Expected 48, got 51. 
    at Error (native) 
    at Object.Module._extensions..node (module.js:597:18) 
    at Module.load (module.js:487:32) 
    at tryModuleLoad (module.js:446:12) 
    at Function.Module._load (module.js:438:3) 
    at Module.require (module.js:497:17) 
    at require (internal/module.js:20:19) 
    at Object.<anonymous> (/builds/focus/focus-api/node_modules/bcrypt/bcrypt.js:6:16) 
    at Module._compile (module.js:570:32) 
    at Object.Module._extensions..js (module.js:579:10) 
    at Module.load (module.js:487:32) 
    at tryModuleLoad (module.js:446:12) 
    at Function.Module._load (module.js:438:3) 
    at Module.require (module.js:497:17) 
    at require (internal/module.js:20:19) 
    at Object.<anonymous> (/builds/focus/focus-api/app/helpers/auth_helper.js:1:78) 
    at Module._compile (module.js:570:32) 
    at Object.Module._extensions..js (module.js:579:10) 
    at Module.load (module.js:487:32) 
    at tryModuleLoad (module.js:446:12) 
    at Function.Module._load (module.js:438:3) 
    at Module.require (module.js:497:17) 
    at require (internal/module.js:20:19) 
    at Object.<anonymous> (/builds/focus/focus-api/config/routes/users.js:4:21) 
    at Module._compile (module.js:570:32) 
    at Object.Module._extensions..js (module.js:579:10) 
    at Module.load (module.js:487:32) 
    at tryModuleLoad (module.js:446:12) 
    at Function.Module._load (module.js:438:3) 
    at Module.require (module.js:497:17) 
    at require (internal/module.js:20:19) 
    at Object.<anonymous> (/builds/focus/focus-api/config/routes/index.js:4:15) 
    at Module._compile (module.js:570:32) 
    at Object.Module._extensions..js (module.js:579:10) 
    at Module.load (module.js:487:32) 
    at tryModuleLoad (module.js:446:12) 
    at Function.Module._load (module.js:438:3) 
    at Module.require (module.js:497:17) 
    at require (internal/module.js:20:19) 
    at Object.<anonymous> (/builds/focus/focus-api/app.js:8:16) 
    at Module._compile (module.js:570:32) 
    at Object.Module._extensions..js (module.js:579:10) 
    at Module.load (module.js:487:32) 
    at tryModuleLoad (module.js:446:12) 
    at Function.Module._load (module.js:438:3) 
    at Module.require (module.js:497:17) 
    at require (internal/module.js:20:19) 
    at Object.<anonymous> (/builds/focus/focus-api/test/integration/routes_auth_test.js:1:75) 
    at Module._compile (module.js:570:32) 
    at Object.Module._extensions..js (module.js:579:10) 
    at Module.load (module.js:487:32) 
    at tryModuleLoad (module.js:446:12) 
    at Function.Module._load (module.js:438:3) 
    at Module.require (module.js:497:17) 
    at require (internal/module.js:20:19) 
    at /builds/focus/focus-api/node_modules/mocha/lib/mocha.js:222:27 
    at Array.forEach (native) 
    at Mocha.loadFiles (/builds/focus/focus-api/node_modules/mocha/lib/mocha.js:219:14) 
    at Mocha.run (/builds/focus/focus-api/node_modules/mocha/lib/mocha.js:487:10) 
    at Object.<anonymous> (/builds/focus/focus-api/node_modules/mocha/bin/_mocha:459:18) 
    at Module._compile (module.js:570:32) 
    at Object.Module._extensions..js (module.js:579:10) 
    at Module.load (module.js:487:32) 
    at tryModuleLoad (module.js:446:12) 
    at Function.Module._load (module.js:438:3) 
    at Module.runMain (module.js:604:10) 
    at run (bootstrap_node.js:394:7) 
    at startup (bootstrap_node.js:149:9) 
    at bootstrap_node.js:509:3 
npm info lifecycle [email protected]~test: Failed to exec test script 
npm ERR! Test failed. See above for more details. 
ERROR: Job failed: exit code 1 

感謝任何指向正確的方向,謝謝你的幫助!

+4

'NPM rebuild' - 如果沒有幫助,然後--- '室射頻node_modules && NPM安裝' – oklas

+0

<我看過這個,看來這是我的問題的原因,因爲在我的本地測試npm測試運行良好,但在gitlab亞軍它給版本不匹配問題>當您使用版本號範圍,而不是確切的版本有一個重要的後果。你不能像以後那樣重複構建。安裝的版本取決於您運行npm install的時間。現在它可能會安裝不同的依賴項,而不是它今天安裝的版本。對於那些依賴可重複性的情況來說,這是不令人滿意的。生產部署和公開發布的情況就是如此。 – Buddhi

+0

這篇參考文章討論了使用版本號範圍而不是確切版本的後果:https://bytearcher.com/articles/semver-explained-why-theres-a-caret-in-my-package-json/ – Buddhi

回答

0

我只是固定的版本,所以故宮將不會更新包 包鎖會在這種情況下幫助

相關問題