Disable fetching package information from NPM and Bower in Visual Studio Code
Overview
This script improves your privacy on Linux.
These changes use Linux system commands to update your settings.
Visual Studio Code fetches data from NPM and Bower to provide autocompletion and hover information
for npm dependencies 1. By default, this feature is enabled 2 and fetches data from
https://registry.npmjs.org
and https://registry.bower.io
1.
This script prevents the automatic fetching of package information.
You can disable this feature by setting npm.fetchOnlinePackageInfo
to false
2.
This script uses Bash (Shell script) scripting language.
This script should only be used by advanced users. This script is not recommended for daily use as it breaks important functionality. Do not run it without having backups and system snapshots.
Implementation Details
-
Language: bash
-
Required Privileges: Root/sudo access
-
Compatibility: Linux only
-
Reversibility: Can be undone using provided revert script
Explore Categories
- Disable Visual Studio Code data collection
- Configure programs
This action belongs to Disable Visual Studio Code data collection category. Visual Studio Code, also commonly referred to as VS Code, is a source-code editor made by Microsoft. Visual Studio Code makes outgoing network requests to collect data in the background without users invoking a feature that requires online access. The requests include, but are not limited to,... Read more on category page ▶
This action belongs to Configure programs category. These scripts configure third-party applications installed on Linux distributions to harden their security and privacy to protect your data. They scripts differ from OS level configurations as they configure applications that are not typically native to Linux distributions, i.e., not included in... Read more on category page ▶
Apply now
Choose one of three ways to apply:
- Automatically via privacy.sexy: The easiest and safest option.
- Manually by downloading: Requires downloading a file.
- Manually by copying: Advanced flexibility.
Alternative 1. Apply with Privacy.sexy
privacy.sexy is free and open-source application that lets securely apply this action easily.
You can fully restore this action (revert back to the original behavior) using the application.
privacy.sexy instructions
- Open or download the desktop application
- Search for the script name:
Disable fetching package information from NPM and Bower in Visual Studio Code
. - Check the script by clicking on the checkbox.
- Click on Run button at the bottom of the page.
Alternative 2. Download
This script is irreversible, meaning there is no straightforward method to restore changes once applied. Exercise caution before running, restoring it may not be possible.
-
Download the script file by clicking on the button below:
-
Run the script file by clicking on it.
Download revert script
This file restores your system to its original state, before this script is applied.
Alternative 3. Copy
This is for advanced users. Consider automatically applying or downloading the script for simpler way.
-
Open Terminal
-
Copy the following code:
if ! command -v 'python3' &> /dev/null; then
echo 'Skipping because "python3" is not found.'
else
python3 <<EOF
from pathlib import Path
import os, json, sys
property_name = 'npm.fetchOnlinePackageInfo'
target = json.loads('false')
home_dir = f'/home/{os.getenv("SUDO_USER", os.getenv("USER"))}'
settings_files = [
# Global installation (also Snap that installs with "--classic" flag)
f'{home_dir}/.config/Code/User/settings.json',
# Flatpak installation
f'{home_dir}/.var/app/com.visualstudio.code/config/Code/User/settings.json'
]
for settings_file in settings_files:
file=Path(settings_file)
if not file.is_file():
print(f'Skipping, file does not exist at "{settings_file}".')
continue
print(f'Reading file at "{settings_file}".')
file_content = file.read_text()
if not file_content.strip():
print('Settings file is empty. Treating it as default empty JSON object.')
file_content = '{}'
json_object = None
try:
json_object = json.loads(file_content)
except json.JSONDecodeError:
print(f'Error, invalid JSON format in the settings file: "{settings_file}".', file=sys.stderr)
continue
if property_name not in json_object:
print(f'Settings "{property_name}" is not configured.')
else:
existing_value = json_object[property_name]
if existing_value == target:
print(f'Skipping, "{property_name}" is already configured as {json.dumps(target)}.')
continue
print(f'Setting "{property_name}" has unexpected value {json.dumps(existing_value)} that will be changed.')
json_object[property_name] = target
new_content = json.dumps(json_object, indent=2)
file.write_text(new_content)
print(f'Successfully configured "{property_name}" to {json.dumps(target)}.')
EOF
fi
- Paste the code into terminal.
- Press Enter to apply the code.
Some scripts requires restarting your computer to take affect.
Copy restore code
Copy and run the following code to restore changes:
if ! command -v 'python3' &> /dev/null; then
>&2 echo 'Cannot revert because "python3" is not found.'
else
python3 <<EOF
from pathlib import Path
import os, json, sys
property_name = 'npm.fetchOnlinePackageInfo'
target = json.loads('false')
home_dir = f'/home/{os.getenv("SUDO_USER", os.getenv("USER"))}'
settings_files = [
# Global installation (also Snap that installs with "--classic" flag)
f'{home_dir}/.config/Code/User/settings.json',
# Flatpak installation
f'{home_dir}/.var/app/com.visualstudio.code/config/Code/User/settings.json'
]
for settings_file in settings_files:
file=Path(settings_file)
if not file.is_file():
print(f'Skipping, file does not exist at "{settings_file}".')
continue
print(f'Reading file at "{settings_file}".')
file_content = file.read_text()
if not file_content.strip():
print(f'Skipping, no need to revert because settings file is empty: "{settings_file}".')
continue
try:
json_object = json.loads(file_content)
except json.JSONDecodeError:
print(f'Error, invalid JSON format in the settings file: "{settings_file}".', file=sys.stderr)
continue
if property_name not in json_object:
print(f'Skipping, "{property_name}" is not configured.')
continue
existing_value = json_object[property_name]
if existing_value != target:
print(f'Skipping, "{property_name}" is configured using {json.dumps(existing_value)} instead of {json.dumps(target)}.')
continue
del json_object[property_name]
new_content = json.dumps(json_object, indent=2)
file.write_text(new_content)
print(f'Successfully reverted "{property_name}" setting.')
EOF
fi
Support
This website relies on your support.
Your donation helps keep the project alive and improves its content ❤️.
Share this page: