简体   繁体   English

如何找到没有相对路径的ES6导入模块?

[英]How to find an ES6 import module without a relative path?

I have an ES6 import. 我有一个ES6导入。

import MyAwesomeComponent from 'packageNameOnlyWithoutPath';

I want to inspect the file packageNameOnlyWithoutPath . 我想检查文件packageNameOnlyWithoutPath But I can't find it. 但是我找不到。 I looked in node_modules but I don't see it there. 我查看了node_modules但在node_modules看不到。 So it might be hiding out elsewhere in the app. 因此它可能隐藏在应用程序的其他位置。

Is there a canonical way to find the path that leads to packageNameOnlyWithoutPath ? 有没有找到通往packageNameOnlyWithoutPath的路径的规范方法?

you might want to take a look at index.js file in the packageNameOnlyWithoutPath folder inside the node_modules. 您可能想看看node_modules内packageNameOnlyWithoutPath文件夹中的index.js文件。 Else use text editors which supports goToDefinition plugin 其他使用支持goToDefinition插件的文本编辑器

TL;DR: Check resolve aliases in Webpack (or similar bundler) config or .babelrc TL; DR:在Webpack(或类似的捆绑程序)配置或.babelrc检查解析别名

There's two places you can check first. 您可以先检查两个地方。

  1. If you are using a bundler like Webpack, resolve aliases can be declared in the Webpack config file (usually webpack.config.js). 如果您使用像Webpack这样的捆绑程序,则可以在Webpack配置文件(通常是webpack.config.js)中声明解析别名。
  2. But I have also recently started using pure babel and node. 但是我最近也开始使用纯babel和node。 The reoslves can also be declared in the .babelrc file (cleaner approach IMHO). 也可以在.babelrc文件中声明重新存储(更干净的方法IMHO)。

You should find what you're looking for in one of the above. 您应该在上述之一中找到所需的内容。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM