gpt4 book ai didi

javascript - 如何使用 Node js 和 babel 保留正确的行号

转载 作者:数据小太阳 更新时间:2023-10-29 05:37:58 25 4
gpt4 key购买 nike

我有以下设置并且我的错误/堆栈跟踪有问题我是否遗漏了什么?

package.json 看起来像:

{
"name": "xxxxxx",
"main": "server.js",
"private": true,
"scripts": {
"start": "nodemon --exec ./node_modules/.bin/babel-node server.js"
},
"dependencies": {
"babel": "^6.5.2",
"babel-cli": "^6.6.5",
"babel-preset-es2015": "^6.6.0",
"babel-preset-react": "^6.5.0",
"babel-preset-stage-0": "^6.5.0",
"babel-runtime": "^6.6.1"
}
}

.babelrc 看起来像:

{
presets: ["es2015", "stage-0", "react"],
sourceMap: 'inline',
retainLines: true
}

server.js 看起来像:

let aVar = '';

throw new Error('some error');
import errorHandler from './app/middlewares/error_handler';

我的堆栈跟踪很疯狂

module.js:341
throw err;
^
Error: Cannot find module 'bugsnag'
at Function.Module._resolveFilename (module.js:339:15)
at Function.Module._load (module.js:290:25)
at Module.require (module.js:367:17)
at require (internal/module.js:16:19)
at Object.<anonymous> (/home/projectName/lib/util/error.js:14:113)
at Module._compile (module.js:413:34)
at loader (/home/projectName/node_modules/babel-register/lib/node.js:126:5)
at Object.require.extensions.(anonymous function) [as .js] (/home/projectName/node_modules/babel-register/lib/node.js:136:7)
at Module.load (module.js:357:32)
at Function.Module._load (module.js:314:12)
at Module.require (module.js:367:17)
at require (internal/module.js:16:19)
at Object.<anonymous> (/home/projectName/app/middlewares/error_handler.js:11:91)
at Module._compile (module.js:413:34)
at loader (/home/projectName/node_modules/babel-register/lib/node.js:126:5)
at Object.require.extensions.(anonymous function) [as .js] (/home/projectName/node_modules/babel-register/lib/node.js:136:7)
at Module.load (module.js:357:32)
at Function.Module._load (module.js:314:12)
at Module.require (module.js:367:17)
at require (internal/module.js:16:19)
at Object.<anonymous> (/home/projectName/server.js:15:22)
at Module._compile (module.js:413:34)

如您所见,这看起来不对而且很难理解。我相信有办法解决这个问题。

最佳答案

您似乎缺少“bugsnag”模块。尝试:

npm install -g bugsnag

关于javascript - 如何使用 Node js 和 babel 保留正确的行号,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36235357/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com