Sublime Forum

PostCSS Sorting Couldn't find Node.js. Make sure it's in your $PATH by running `node -v` in your command-line

#1

Can anyone assist me with this issue? I can’t seem to find the issue and could use a little assistance. Appreciate any help.

27%20PM

0 Likes

#2

What was the result of running node -v on the command line?

0 Likes

#3

When I run node -v I get this result: v16.15.0 - I even told nvm to use that specific version.

0 Likes

#4

What OS are you on? This kind of problem can happen on MacOS in cases where the Terminal has access to the appropriate $PATH environment variable but Sublime doesn’t, for example.

0 Likes

#5

I’m using macOS

0 Likes

#6

Is there any kind of solution to this issue?

0 Likes

#7

It appears the package incorrectly tries to extend $PATH variable on MacOS, which may drive it invalid. IMHO, line 14 misses : path separator.

It should proabably look like env['PATH'] += ':' + os.path.expanduser('~/n/bin').


ST4 reads environment variables such as $PATH from login shell upon startup. Hence, I’d guess, the whole block (line 11 to 15) is no longer needed.


Package seems no longer maintained, so patching locally seems to be the only option.

node_bridge.py

import os
import platform
import subprocess

IS_OSX = platform.system() == 'Darwin'
IS_WINDOWS = platform.system() == 'Windows'

def node_bridge(data, bin, args=[]):
	startupinfo = None
	if IS_WINDOWS:
		startupinfo = subprocess.STARTUPINFO()
		startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
	try:
		p = subprocess.Popen(['node', bin] + args,
			stdout=subprocess.PIPE, stdin=subprocess.PIPE, stderr=subprocess.PIPE,
			startupinfo=startupinfo)
	except OSError:
		raise Exception('Couldn\'t find Node.js. Make sure it\'s in your $PATH by running `node -v` in your command-line.')
	stdout, stderr = p.communicate(input=data.encode('utf-8'))
	stdout = stdout.decode('utf-8')
	stderr = stderr.decode('utf-8')
	if stderr:
		raise Exception('Error: %s' % stderr)
	else:
		return stdout
1 Like

#8

Oh, my goodness. This is wonderful - and I would be remiss if I didn’t thank you both for taking the time to assist me. It is very much appreciated. I’ll try this solution later this evening. I’ll report back.

1 Like