Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nodePath not working (vscode-tslint) #179

Closed
maxdeviant opened this issue Mar 3, 2017 · 3 comments
Closed

nodePath not working (vscode-tslint) #179

maxdeviant opened this issue Mar 3, 2017 · 3 comments

Comments

@maxdeviant
Copy link

maxdeviant commented Mar 3, 2017

You can read the original issues description in vscode-tslint #173.

Whenever I try to set a nodePath for vscode-tslint, it always ends up using the global node_modules path.

You can see that even though the NODE_PATH has a value, it still continues on to call resolveGlobalNodePath.

[Trace - 10:24:16 AM] NODE_PATH value is: c:\Projects\CloudTestGrading\node_modules\@remark\typescript\node_modules
[Trace - 10:24:17 AM] 'npm config get prefix' value is: C:\Program Files\nodejs
[Trace - 10:24:17 AM] NODE_PATH value is: C:\Program Files\nodejs\node_modules

From server/src/files.ts:

export function resolveModulePath(workspaceRoot: string, moduleName: string, nodePath: string, tracer: (message: string, verbose?: string) => void): Thenable<string> {
	if (nodePath) {
		if (!path.isAbsolute(nodePath)) {
			nodePath = path.join(workspaceRoot, nodePath);
		}
		return resolve(moduleName, nodePath, nodePath, tracer).then((value) => {
                        // This line seems to be the culprit
			if (value.indexOf(path.normalize(nodePath)) === 0) {
				return value;
			} else {
				return Promise.reject<string>(new Error(`Failed to load ${moduleName} from node path location.`));
			}
		}).then(undefined, (_error: any) => {
                        // We are passing a custom nodePath that _should_ be valid,
                        // so we do not expect this to be called.
			return resolve(moduleName, resolveGlobalNodePath(tracer), workspaceRoot, tracer);
		});
	} else {
		return resolve(moduleName, resolveGlobalNodePath(tracer), workspaceRoot, tracer);
	}
}
@maxdeviant
Copy link
Author

Environment Info:

OS: Windows 7
Node: v7.7.1
VSCode: v1.10.1
vscode-tslint: v0.8.1

@maxdeviant
Copy link
Author

I have been trying to assemble a test case to illustrate the problem, but unfortunately there isn't any test coverage for the server code, and it looks like all of the resolve functions are pretty tightly coupled to the outside world.

@dbaeumer
Copy link
Member

dbaeumer commented Mar 7, 2017

I fixed this on the server to correctly handling the path comparison.

@dbaeumer dbaeumer closed this as completed Mar 7, 2017
@vscodebot vscodebot bot locked and limited conversation to collaborators Nov 21, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants