node.js - 为什么在PhpStorm/WebStorm中自动导入生成根 Node 模块的相对路径

标签 node.js ide phpstorm webstorm

我的项目结构:

/website
   /node
     /node_module <<-- library root
     /type_src  <<-- ts files
     /src  <<-- compiled js files

我曾经能够像这样自动导入根 Node 模块:

/type_src/store/BaseStore.ts:

import {observer} from "mobx-react/native";
@observer
class BaseStore{

}

但最近,自动导入为这些 Node 模块生成了相对路径:

import {observer} from "../../node_modules/mobx-react/index";
@observer
class BaseStore{

}

生成 import {observer} from "mobx-react/native"; 的唯一方法是等待那个红色灯泡出现,这不太方便。

我已经创建了另一个项目并且它工作正常,但我不知道为什么这个项目突然出现这个问题。谁能帮我解决这个问题?

配置文件:

{
  "compilerOptions": {
    "module": "commonjs",
    "target": "es6",
    "moduleResolution": "node",
    "removeComments": true,
    "allowSyntheticDefaultImports": true,
    "noImplicitAny": false,
    "sourceMap": true,
    "outDir": "./src",
    "jsx": "react",
    "experimentalDecorators": true,
    "noLib": false,
    "declaration": false,
    "emitDecoratorMetadata": true,
    "lib": ["es6", "dom"],
    "types": ["reflect-metadata"]
  },
  "exclude": [
    "node_modules"
  ]
}

enter image description here

enter image description here

最佳答案

根据引用链接,它是(已修复)webstorm 中的错误。

解决方案 - 升级到 2017.1 或更高版本

关于node.js - 为什么在PhpStorm/WebStorm中自动导入生成根 Node 模块的相对路径,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42464774/

相关文章:

go - golang 的 Geany 符号列表

intellij-idea - PHPStorm 中是否有删除当前打开文件的快捷方式?

ruby - 在 Windows 上使用 PHPStorm 使用 SASS 进行开发

javascript - 如何使用 Node.js Cassandra 驱动程序运行连续查询?

javascript - Babelify 和原生 Node 模块

delphi - 为什么 Delphi XE2 不允许我将字体资源嵌入为 RCDATA?

delphi - Delphi IDE 的增强型 Object Inspector Expert 插件

php - phpstorm中如何设置行注释的样式

javascript - 如何使用nodejs读取请求中的动态json

node.js - 类型错误 : Cannot use 'in' operator to search for '$__firebase' in undefined