Change working directory in my current shell context when running Node script

The correct way to change directories is actually with process.chdir(directory). Here’s an example from the documentation: console.log(‘Starting directory: ‘ + process.cwd()); try { process.chdir(‘/tmp’); console.log(‘New directory: ‘ + process.cwd()); } catch (err) { console.log(‘chdir: ‘ + err); } This is also testable in the Node.js REPL: [monitor@s2 ~]$ node > process.cwd() ‘/home/monitor’ > process.chdir(‘../’); undefined … Read more

Equivalent of shell ‘cd’ command to change the working directory?

You can change the working directory with: import os os.chdir(path) There are two best practices to follow when using this method: Catch the exception (WindowsError, OSError) on invalid path. If the exception is thrown, do not perform any recursive operations, especially destructive ones. They will operate on the old path and not the new one. … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)