Description: use system shared NodeJS modules
 Also, use native wasm2c.
 See also <https://github.com/emscripten-core/emscripten/issues/12688>
Author: Jonas Smedegaard <dr@jones.dk>
Last-Update: 2021-11-19
---
This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
--- a/tools/shared.py
+++ b/tools/shared.py
@@ -237,11 +237,11 @@
 
 def get_npm_cmd(name):
   if WINDOWS:
-    cmd = [path_from_root('node_modules/.bin', name + '.cmd')]
+    cmd = name + '.cmd'
   else:
-    cmd = config.NODE_JS + [path_from_root('node_modules/.bin', name)]
+    cmd = name
   if not os.path.exists(cmd[-1]):
-    exit_with_error(f'{name} was not found! Please run "npm install" in Emscripten root directory to set up npm dependencies')
+    exit_with_error(f'{name} was not found! Please report this as a bug against emscripten - more info at https://www.debian.org/Bugs/Reporting')
   return cmd
 
 
--- a/tools/wasm2c.py
+++ b/tools/wasm2c.py
@@ -78,8 +78,8 @@
 
 def do_wasm2c(infile):
   assert settings.STANDALONE_WASM
-  WASM2C = config.NODE_JS + [path_from_root('node_modules/wasm2c/wasm2c.js')]
-  WASM2C_DIR = path_from_root('node_modules/wasm2c')
+  WASM2C = ['wasm2c']
+  WASM2C_DIR = '/usr/src/wasm2c'
   c_file = unsuffixed(infile) + '.wasm.c'
   h_file = unsuffixed(infile) + '.wasm.h'
   cmd = WASM2C + [infile, '-o', c_file]
--- a/tests/test_sockets.py
+++ b/tests/test_sockets.py
@@ -164,11 +164,6 @@
     print('Running the socket tests. Make sure the browser allows popups from localhost.')
     print()
 
-    # Use emscripten root for node module lookup.  This is needed because the unit tests each
-    # run with CWD set to a temporary directory outside the emscripten tree.
-    print('Setting NODE_PATH=' + path_from_root('node_modules'))
-    os.environ['NODE_PATH'] = path_from_root('node_modules')
-
   def test_sockets_echo(self, extra_args=[]):
     sockets_include = '-I' + test_file('sockets')
 
