0
我已經使用此代碼與我的node.js應用程序與快速但上傳到Heroku時我運行時出現錯誤。快速app.use語法錯誤
2016-09-28T11:01:40.502448+00:00 app[web.1]: /app/routes/index.js:146
2016-09-28T11:01:40.502467+00:00 app[web.1]: app.use(({method, url}, rsp, next) => {
2016-09-28T11:01:40.502468+00:00 app[web.1]: ^
2016-09-28T11:01:40.502468+00:00 app[web.1]:
2016-09-28T11:01:40.502469+00:00 app[web.1]: SyntaxError: Unexpected token {
2016-09-28T11:01:40.502469+00:00 app[web.1]: at exports.runInThisContext (vm.js:53:16)
2016-09-28T11:01:40.502470+00:00 app[web.1]: at Module._compile (module.js:387:25)
2016-09-28T11:01:40.502471+00:00 app[web.1]: at Object.Module._extensions..js (module.js:422:10)
2016-09-28T11:01:40.502471+00:00 app[web.1]: at Module.load (module.js:357:32)
2016-09-28T11:01:40.502472+00:00 app[web.1]: at Function.Module._load (module.js:314:12)
2016-09-28T11:01:40.502473+00:00 app[web.1]: at Module.require (module.js:367:17)
2016-09-28T11:01:40.502473+00:00 app[web.1]: at require (internal/module.js:20:19)
2016-09-28T11:01:40.502474+00:00 app[web.1]: at Object.<anonymous> (/app/app.js:8:14)
2016-09-28T11:01:40.502474+00:00 app[web.1]: at Module._compile (module.js:413:34)
2016-09-28T11:01:40.502475+00:00 app[web.1]: at Object.Module._extensions..js (module.js:422:10)
我的代碼是
app.use(({method, url}, rsp, next) => {
rsp.on('finish',() => {
console.log(`${rsp.statusCode} ${method} ${url}`);
});
next();
});
任何幫助,將不勝感激
我的包中沒有引擎部分,json。我只有{ 「名」:「廁所, 「版本」: 「1.0.0」, 「說明」: 「」, 「主」: 「index.js」, 「腳本」:{ 「test」:「echo」錯誤:未指定測試\「&& exit 1」, 「start」:「node index.js」 }, 「dependencies」:{ 「body-parser」:「〜1.15 「1」, 「connect-mongo」:「^ 1.3.2」, 「connect-redis」:「^ 3.1.0」, 「cookie-parser」:「^ 1.4.3」, 「debug」 :「〜2.2.0」, 「dotenv」:「^ 2.0.0」, 「express」:「〜4.13.4」, 「feed-read」:「0.0.1」, 「fs」: 「0.0.2」, 「http」:「0.0.0」, } } – user1907509
我將添加此引擎部分,然後再試一次 – user1907509
是的,確保您在package.json中包含所有必需的依賴關係,因爲當您上傳到Heroku時,它將只安裝列出的那些。此外,你是否錯過了「名稱」後面的「關閉」:「wc? –