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

[Bug]: About Warn Failed to resolve global node_modules path. #386

Open
1 task done
Saszr opened this issue Mar 23, 2022 · 9 comments
Open
1 task done

[Bug]: About Warn Failed to resolve global node_modules path. #386

Saszr opened this issue Mar 23, 2022 · 9 comments
Labels
status: needs reproducible example triage needs reproducible demo or repo type: bug a problem with a feature or rule

Comments

@Saszr
Copy link

Saszr commented Mar 23, 2022

How did you encounter this bug?

I have not installed the global dependencies, the plugin has successfully run the relevant configuration through the installation in the project node_modules, but it still prompts me that the global dependencies are missing.

Code Snippet

No response

Stylelint Configuration

No response

Extension Configuration

No response

Actual Behaviour

I don't understand if this is a bug or a friendly prompt. 😯

Expected Behaviour

Maybe in my case it could have done without the hint.

Logs

[Info - 6:06:19 PM] [language-server] Registering module | module: "auto-fix"
[Info - 6:06:19 PM] [language-server] Module registered | module: "auto-fix"
[Info - 6:06:19 PM] [language-server] Registering module | module: "code-action"
[Info - 6:06:19 PM] [language-server] Module registered | module: "code-action"
[Info - 6:06:19 PM] [language-server] Registering module | module: "completion"
[Info - 6:06:19 PM] [language-server] Module registered | module: "completion"
[Info - 6:06:19 PM] [language-server] Registering module | module: "formatter"
[Info - 6:06:19 PM] [language-server] Module registered | module: "formatter"
[Info - 6:06:19 PM] [language-server] Registering module | module: "old-stylelint-warning"
[Info - 6:06:19 PM] [language-server] Module registered | module: "old-stylelint-warning"
[Info - 6:06:19 PM] [language-server] Registering module | module: "validator"
[Info - 6:06:19 PM] [language-server] Module registered | module: "validator"
[Info - 6:06:19 PM] [language-server] Starting language server
[Info - 6:06:19 PM] [language-server] Registering handlers
[Info - 6:06:19 PM] [language-server] Handlers registered
[Info - 6:06:19 PM] [language-server] Language server started
[Warn - 6:06:20 PM] [language-server] Failed to resolve global node_modules path. | packageManager: "npm" error: {"errno":-2,"code":"ENOENT","syscall":"spawn npm","path":"npm","spawnargs":["config","get","prefix"],"name":"Error","message":"spawn npm ENOENT","stack":"Error: spawn npm ENOENT\n at Process.ChildProcess._handle.onexit (internal/child_process.js:269:19)\n at onErrorNT (internal/child_process.js:465:16)\n at processTicksAndRejections (internal/process/task_queues.js:80:21)"}
[Warn - 6:06:20 PM] [language-server] Failed to resolve global node_modules path. | packageManager: "npm" error: {"errno":-2,"code":"ENOENT","syscall":"spawn npm","path":"npm","spawnargs":["config","get","prefix"],"name":"Error","message":"spawn npm ENOENT","stack":"Error: spawn npm ENOENT\n at Process.ChildProcess._handle.onexit (internal/child_process.js:269:19)\n at onErrorNT (internal/child_process.js:465:16)\n at processTicksAndRejections (internal/process/task_queues.js:80:21)"}
[Warn - 6:06:20 PM] [language-server] Failed to resolve global node_modules path. | packageManager: "npm" error: {"errno":-2,"code":"ENOENT","syscall":"spawn npm","path":"npm","spawnargs":["config","get","prefix"],"name":"Error","message":"spawn npm ENOENT","stack":"Error: spawn npm ENOENT\n at Process.ChildProcess._handle.onexit (internal/child_process.js:269:19)\n at onErrorNT (internal/child_process.js:465:16)\n at processTicksAndRejections (internal/process/task_queues.js:80:21)\n at runNextTicks (internal/process/task_queues.js:62:3)\n at processImmediate (internal/timers.js:434:9)"}
/Users/saszr/Coding/Github/rfmo/src/global.less: When linting something other than CSS, you should install an appropriate syntax, e.g. "postcss-less", and use the "customSyntax" option
/Users/saszr/Coding/Github/rfmo/src/global.less: When linting something other than CSS, you should install an appropriate syntax, e.g. "postcss-less", and use the "customSyntax" option

Stylelint Version

v14.6.0

vscode-stylelint Version

v1.2.2

Node.js Version

v16.13.1

Operating System

macOS 12.0.1

Windows Subsystem for Linux

No response

Code of Conduct

  • I agree to follow vscode-stylelint's Code of Conduct
@Saszr Saszr added the type: bug a problem with a feature or rule label Mar 23, 2022
@luke-underwood
Copy link

I just ran into the same problem. This was also seen in #331

I fixed this by clearing my VS Code caches, and then restarting:

# MacOS
rm -rf $HOME/Library/Application\ Support/Code/Cache/* $HOME/Library/Application\ Support/Code/CachedData/*

I think the problem lies in the global path resolver using a stale cache value:

async resolve(packageManager: PackageManager): Promise<string | undefined> {
const cached = this.#cache[packageManager];
if (cached) {
return cached;
}

@Saszr
Copy link
Author

Saszr commented Mar 24, 2022

I fixed this by clearing my VS Code caches, and then restarting

I did this, but nothing changed, the warn is still there.

@ota-meshi ota-meshi added the status: needs reproducible example triage needs reproducible demo or repo label Aug 17, 2022
@ahenriksen-inferno
Copy link

I'm having this same issue on macOS 13.0.1 and also using NVM. I've installed the stylelint package locally and the VS Code Stylelint plugin works, but I still get the warning message. I've added export NODE_PATH=$(npm root --quiet -g) to my .zshrc file, cleared the VS Code caches and neither helped.

@cl1107
Copy link

cl1107 commented Jan 9, 2023

I'm having this same issue on Windows 11 and using fnm, i‘m using winget install OpenJS.NodeJS.LTS install nodejs to system,solved this problem. maybe add fnm's node and npm path to environment variable can also solved this problem

@arjendevos
Copy link

I got this as well

@acherkashin
Copy link

acherkashin commented Sep 18, 2023

I have the same issue.

I'm using PNPM modules.

VS Code settings I use

    "stylelint.packageManager": "pnpm",
    "stylelint.configFile": ".stylelintrc.js"

Warning

[Info  - 08:46:00] [language-server] Registering module | module: "auto-fix"
[Info  - 08:46:00] [language-server] Module registered | module: "auto-fix"
[Info  - 08:46:01] [language-server] Registering module | module: "code-action"
[Info  - 08:46:01] [language-server] Module registered | module: "code-action"
[Info  - 08:46:01] [language-server] Registering module | module: "completion"
[Info  - 08:46:01] [language-server] Module registered | module: "completion"
[Info  - 08:46:01] [language-server] Registering module | module: "formatter"
[Info  - 08:46:01] [language-server] Module registered | module: "formatter"
[Info  - 08:46:01] [language-server] Registering module | module: "old-stylelint-warning"
[Info  - 08:46:01] [language-server] Module registered | module: "old-stylelint-warning"
[Info  - 08:46:01] [language-server] Registering module | module: "validator"
[Info  - 08:46:01] [language-server] Module registered | module: "validator"
[Info  - 08:46:01] [language-server] Starting language server
[Info  - 08:46:01] [language-server] Registering handlers
[Info  - 08:46:01] [language-server] Handlers registered
[Info  - 08:46:01] [language-server] Language server started
[Warn  - 08:46:06] [language-server] Failed to resolve global node_modules path. | packageManager: "pnpm" error: {"name":"Error","message":"Command \"pnpm\" exited with code 1.","stack":"Error: Command \"pnpm\" exited with code 1.\n    at p (/Users/cherkalexander/.vscode/extensions/stylelint.vscode-stylelint-1.2.4/dist/start-server.js:70:20149)\n    at ChildProcess.<anonymous> (/Users/cherkalexander/.vscode/extensions/stylelint.vscode-stylelint-1.2.4/dist/start-server.js:70:20440)\n    at ChildProcess.emit (node:events:513:28)\n    at ChildProcess._handle.onexit (node:internal/child_process:291:12)"}
[Warn  - 08:46:06] [language-server] Failed to resolve global node_modules path. | packageManager: "pnpm" error: {"name":"Error","message":"Command \"pnpm\" exited with code 1.","stack":"Error: Command \"pnpm\" exited with code 1.\n    at p (/Users/cherkalexander/.vscode/extensions/stylelint.vscode-stylelint-1.2.4/dist/start-server.js:70:20149)\n    at ChildProcess.<anonymous> (/Users/cherkalexander/.vscode/extensions/stylelint.vscode-stylelint-1.2.4/dist/start-server.js:70:20440)\n    at ChildProcess.emit (node:events:513:28)\n    at ChildProcess._handle.onexit (node:internal/child_process:291:12)"}

Stylelint packages

    "stylelint": "^15.10.2",
    "stylelint-config-standard": "^34.0.0",
    "stylelint-declaration-strict-value": "^1.9.2",

Pnpm version: v7.17.1

Stylelint Version: v1.2.4

Node.js Version: v16.15.1

Operating System macOS 13.0.1

If I remove stylelint.packageManager setting, the warning goes away. But Fix all auto-fixable problems action doesn't work for me.

@khancerberus
Copy link

I'm having this same issue on Windows 11 and using fnm, i‘m using winget install OpenJS.NodeJS.LTS install nodejs to system,solved this problem. maybe add fnm's node and npm path to environment variable can also solved this problem

I think this is an environment variable error. I also used the fnm tool with windows 10, and decided to install node to the system and it worked for me.

@profaurore
Copy link

profaurore commented Feb 25, 2024

I am also receiving this error.

I believe this to be caused by a breaking change from Yarn Classic to Yarn Modern: the yarn global command, which is used to determine the global path for node modules, was removed. Note that other command names were also changed, which may affect areas other than the one I highlighted above.

I suspect that the desired new command for the case I highlighted above is yarn config get cacheFolder, though reading from the directory may require additional changes.

@baixjian
Copy link

baixjian commented Mar 7, 2024

I got this as well

 "dependencies": {
    "postcss": "^8.4.16",
    "postcss-less": "^6.0.0",
    "postcss-html": "^1.6.0",
    "postcss-scss": "^4.0.0",
    "stylelint": "^16.2.1",
    "stylelint-config-standard": "^36.0.0",
    "stylelint-config-css-modules": "^4.4.0",
    "stylelint-config-recess-order": "^5.0.0",
    "stylelint-config-recommended-vue": "^1.5.0",
    "stylelint-config-standard-scss": "^13.0.0",
    "stylelint-scss": "^6.2.1"
  },

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: needs reproducible example triage needs reproducible demo or repo type: bug a problem with a feature or rule
Projects
None yet
Development

No branches or pull requests

10 participants