2016-01-04 140 views
0

我想部署我的node.js應用到heroku。 我得到的git push heroku master此錯誤:錯誤部署node.js應用到heroku

> [email protected] test /tmp/build_4d6fe429e576b4e42425b713c87264e9/node_modules/response-time/node_modules/on-headers 
    > mocha --reporter spec --bail --check-leaks test/ 

    /tmp/build_4d6fe429e576b4e42425b713c87264e9/node_modules/mocha/lib/utils.js:626 
    throw new Error("cannot resolve path (or pattern) '" + path + "'"); 
^

    Error: cannot resolve path (or pattern) 'test/' 
    at Object.lookupFiles (/tmp/build_4d6fe429e576b4e42425b713c87264e9/node_modules/mocha/lib/utils.js:626:15) 
    at /tmp/build_4d6fe429e576b4e42425b713c87264e9/node_modules/mocha/bin/_mocha:316:30 
    at Array.forEach (native) 
    at Object.<anonymous> (/tmp/build_4d6fe429e576b4e42425b713c87264e9/node_modules/mocha/bin/_mocha:315:6) 
    at Module._compile (module.js:435:26) 
    at Object.Module._extensions..js (module.js:442:10) 
    at Module.load (module.js:356:32) 
    at Function.Module._load (module.js:311:12) 
    at Function.Module.runMain (module.js:467:10) 
    at startup (node.js:136:18) 
    at node.js:963:3 

    > [email protected] test /tmp/build_4d6fe429e576b4e42425b713c87264e9/node_modules/soluto-monitor/node_modules/node-statsd 
    > mocha -R spec 

    /tmp/build_4d6fe429e576b4e42425b713c87264e9/node_modules/mocha/lib/utils.js:626 
    throw new Error("cannot resolve path (or pattern) '" + path + "'"); 
^

    Error: cannot resolve path (or pattern) 'test' 
    at Object.lookupFiles (/tmp/build_4d6fe429e576b4e42425b713c87264e9/node_modules/mocha/lib/utils.js:626:15) 
    at /tmp/build_4d6fe429e576b4e42425b713c87264e9/node_modules/mocha/bin/_mocha:316:30 
    at Array.forEach (native) 
    at Object.<anonymous> (/tmp/build_4d6fe429e576b4e42425b713c87264e9/node_modules/mocha/bin/_mocha:315:6) 
    at Module._compile (module.js:435:26) 
    at Object.Module._extensions..js (module.js:442:10) 
    at Module.load (module.js:356:32) 
    at Function.Module._load (module.js:311:12) 
    at Function.Module.runMain (module.js:467:10) 
    at startup (node.js:136:18) 
    at node.js:963:3 
... 

..和上和爲每個node_modules子目錄中的錯誤Error: cannot resolve path (or pattern) 'test/'

我的package.json看起來或多或少是這樣的:

{ 
    "name": "my-module", 
    "version": "0.1.0", 
    "description": "My Module", 
"dependencies": { 
    "azure-storage": "0.6.0", 
    "bluebird": "3.0.6", 
    "body-parser": "1.14.1", 
    "cors": "2.7.1", 
    "dotenv": "^1.2.0", 
    "express": "3.3.3", 
    "moment": "2.10.6", 
    "request-promise": "1.0.2", 
    "rx": "4.0.7", 
    "shisell": "0.0.2", 
    "striptags": "2.0.4", 
    "winston": "2.1.1" 
    }, 
    "devDependencies": { 
    "chai": "^3.4.1", 
    "chai-as-promised": "^5.1.0", 
    "mocha": "^2.3.4", 
    "mock-require": "^1.2.1", 
    "sinon": "^1.17.2", 
    "sinon-chai": "^2.8.0", 
    "supertest": "^1.1.0" 
    }, 
    "main": "server.js", 
    "engines": { 
    "node": "4.2.3" 
    }, 
    "scripts": { 
    "test": "mocha" 
    } 
} 

好像摩卡試圖node_modules內運行,每個依賴性內。我設法通過在node_modules目錄之一中運行mocha來本地重現錯誤。

我試着從我的package.json中刪除test腳本,我仍然得到相同的錯誤。

我是新來的heroku部署。據我瞭解,一旦我git推到heroku然後heroku運行npm安裝,如果有測試腳本它會運行。但我不明白是什麼導致它嘗試在node_modules的子目錄中運行mocha(爲什麼即使我沒有在我的package.json中指定測試腳本也會發生這種情況)。

任何想法?

p.s.當我在本地機器上運行時,不會發生這種情況。

回答