Why automatic import creates a relative path for node root modules in PhpStorm / WebStorm

My project structure:

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

Previously, I could automatically import node root modules as follows:

/type_src/store/BaseStore.ts:

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

But recently, automatic imports have created relative paths for these node modules:

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

The only way to generate import {observer} from "mobx-react/native"; is waiting for the appearance of this red light bulb, which is not so convenient.

I created another project, and it works great, but I have no idea why this project suddenly ran into this problem. Can someone help me sort this out?

TSconfig:

 { "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

+9
ide webstorm phpstorm
source share
1 answer

Based on the link, this (already fixed) error in the web storm.

The solution is to upgrade to 2017.1 or higher

0
source share

All Articles