Node.js调试器无法在PhpStorm中解析Webpack别名

时间:2019-04-08 14:43:03

标签: javascript reactjs webpack babel

我已经建立了一个由Webpack编译的React应用。项目路径别名在Webpack配置中定义:

module.exports = {
   resolve: {
       alias: {
           CONST:      path.resolve(__dirname, 'src/js/modules/const'),
       },
   },
}

一切正常-PhpStorm解决了这些别名,构建了没有错误的bundle,我可以在浏览器中打开所有内容。但是,当我在PhpStorm中设置node.js调试实例时,会产生错误:

/home/user/dev/classifieds-front/node_modules/.bin/babel-node --inspect=46361 --debug-brk --presets es2015,react /home/user/dev/classifieds-front/src/js/index.js
Debugger listening on ws://127.0.0.1:46361/3039b4ba-e3ae-4ecf-be21-8cbb8c71bfd0
For help see https://nodejs.org/en/docs/inspector
Debugger attached.
(node:12985) [DEP0062] DeprecationWarning: `node --inspect --debug-brk` is deprecated. Please use `node --inspect-brk` instead.
module.js:549
    throw err;
    ^

Error: Cannot find module '@CONST'
    at Function.Module._resolveFilename (module.js:547:15)
    at Function.Module._load (module.js:474:25)
    at Module.require (module.js:596:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/home/user/dev/classifieds-front/src/js/config/index.js:1:1)
    at Module._compile (module.js:652:30)
    at loader (/home/user/dev/classifieds-front/node_modules/babel-register/lib/node.js:144:5)
    at Object.require.extensions.(anonymous function) [as .js] (/home/user/dev/classifieds-front/node_modules/babel-register/lib/node.js:154:7)
    at Module.load (module.js:565:32)
    at tryModuleLoad (module.js:505:12)
Waiting for the debugger to disconnect...

Process finished with exit code 130 (interrupted by signal 2: SIGINT)

跟踪中的文件具有导入语句:

import { SORT_OPTIONS } from 'CONST';

如果我删除此别名并相对定义路径,调试器将正常启动。我该如何解决?

我的PhpStorm调试配置: debugger config

0 个答案:

没有答案