Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Update import/require paths when a file is moved or renamed - not working

I have a javascript project and find that new vs code feature "Update import paths when a file is moved or renamed" does not work for me. I have tried both: import and require statements. And for both options vs code does nothing about changing path after move or rename.

OS: Ubuntu 16.04
Visual Studio Code version 1.25.0
VS Code user settings:

{  
    "javascript.updateImportsOnFileMove.enabled": "always"  
}  

Have an empty jsconfig.json file in the project folder.

like image 551
valerii.r Avatar asked Sep 06 '25 06:09

valerii.r


2 Answers

So, you need to have a jsconfig.json file in the root path, to make sure all paths work.

like image 103
devcass Avatar answered Sep 07 '25 21:09

devcass


I tried to recreate your problem with the current version of Visual Studio Code (1.44) but I did not stumble on any problems: In File/Preferences/Settings I set the prompt-option for updating imports see image:

Then I created an "app"-folder with the following files see image:

app/appLogic.js

import GLOBAL_VARS from './GLOBAL_VARS/GLOBAL_VARS.js'
console.debug(GLOBAL_VARS.laugh())

app/package.json

{
"type":"module"
}

app/GLOBAL_VARS/GLOBAL_VARS.js

var LAUGH = "haha"
export default {
    laugh(){
        return LAUGH
    }
}

I then moved the JS file "GLOBAL_VARS.js" to a different folder and VS Code suggested automatic imports update with a prompt, just as set in the preferences before see image: