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]: Failed to resolve global node_modules path #331

Closed
1 task done
muuvmuuv opened this issue Nov 18, 2021 · 6 comments
Closed
1 task done

[Bug]: Failed to resolve global node_modules path #331

muuvmuuv opened this issue Nov 18, 2021 · 6 comments

Comments

@muuvmuuv
Copy link

muuvmuuv commented Nov 18, 2021

How did you encounter this bug?

Saving a file with auto formatting enabled

Code Snippet

html {
  font-family: var(--font-sans);
  font-size: 16px;
  font-style: normal;
  font-weight: var(--font-normal);
  font-feature-settings: "calt" 1, "liga" 1;

  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  text-size-adjust: 100%;
}

Extension Configuration

/* eslint-disable unicorn/prefer-module */

const recess = require('stylelint-config-recess-order')

/**
 * Stylelint config.
 *
 * @see https://prettier.io/docs/en/configuration.html
 *
 * @type {import('stylelint').Configuration}
 */
module.exports = {
  plugins: ['stylelint-order'],
  customSyntax: 'postcss-scss',
  extends: [
    'stylelint-config-standard',
    'stylelint-config-recommended-scss',
    'stylelint-prettier/recommended',
  ],
  rules: {
    'selector-type-no-unknown': [
      true,
      {
        ignoreTypes: ['/^ion-/', '/^app-/', '/^form-/'],
      },
    ],
    'selector-pseudo-element-no-unknown': [
      true,
      {
        ignorePseudoElements: ['ng-deep'],
      },
    ],
    'block-closing-brace-newline-before': 'always-multi-line',
    'block-opening-brace-newline-after': 'always-multi-line',
    'property-disallowed-list': [
      'padding',
      'padding-left',
      'padding-right',
      'padding-top',
      'padding-bottom',
      'margin',
      'margin-left',
      'margin-right',
      'margin-top',
      'margin-bottom',
    ],
    // ----------------------------------------------------------
    // Ordering
    'declaration-empty-line-before': [
      'always',
      {
        except: ['first-nested'],
        ignore: ['after-declaration', 'after-comment', 'inside-single-line-block'],
      },
    ],
    'order/properties-order': [
      recess.rules['order/properties-order'].map((group) => ({
        ...group,
        emptyLineBefore: 'always',
        noEmptyLineBetween: true,
      })),
      {
        unspecified: 'bottomAlphabetical',
        emptyLineBeforeUnspecified: 'always',
      },
    ],
    'order/order': [
      [
        // Imports
        { type: 'at-rule', name: 'import' },

        // Inheritance
        { type: 'at-rule', name: 'extend' },
        { type: 'at-rule', name: 'apply' },

        // SCSS Variables
        'dollar-variables',

        // Declarations
        'declarations',

        // CSS Variables
        'custom-properties',

        // Mixins
        { type: 'at-rule', name: 'include' },
        { type: 'at-rule', name: 'mixin' },
        { type: 'at-rule', name: 'add-mixin' },

        // Pseudo-elements
        {
          type: 'rule',
          selector: /^&::[\w-]+/,
          hasBlock: true,
        },

        // Nested Rules
        'rules',

        // Pseudo-classes
        {
          type: 'rule',
          selector: /^&:[\w-]+/,
          hasBlock: true,
        },

        // Nested extending rules
        {
          type: 'rule',
          selector: /^&/,
          hasBlock: true,
        },

        // Media Queries
        { type: 'at-rule', name: 'media', hasBlock: true },
      ],
      {
        unspecified: 'bottom',
      },
    ],
  },
}

Actual Behaviour

Shows an error but it seems to work

Expected Behaviour

Find the path?

Logs

[Warn - 1:59:32 PM] [language-server] Failed to resolve global node_modules path. | packageManager: "pnpm" error: {"errno":-2,"code":"ENOENT","syscall":"spawn pnpm","path":"pnpm","spawnargs":["root","-g"],"name":"Error","message":"spawn pnpm ENOENT","stack":"Error: spawn pnpm 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)"}

Stylelint Version

14.1.0

vscode-stylelint Version

1.1.0

Node.js Version

16

Operating System

macOS 12.0.1 (21A559)

Windows Subsystem for Linux

No response

Code of Conduct

  • I agree to follow vscode-stylelint's Code of Conduct
@muuvmuuv muuvmuuv added the type: bug a problem with a feature or rule label Nov 18, 2021
@adalinesimonian
Copy link
Member

To confirm, you are using Stylelint installed globally using pnpm? This error means that pnpm is not accessible in the environment in which the extension is running, which normally means there's an issue in your setup.

Most likely I would guess that this is due to pnpm not being in the PATH that's made available to applications launched outside of the terminal. I'm not certain if this has changed between macOS 10.10 and 12.0, but take a look at https://apple.stackexchange.com/questions/51677/how-to-set-path-for-finder-launched-applications for instructions on how to edit this PATH.

For now, I'm closing this since it seems to be an issue with the environment as opposed to a bug with the extension.

@adalinesimonian adalinesimonian added External and removed type: bug a problem with a feature or rule labels Nov 18, 2021
@muuvmuuv
Copy link
Author

Stylelint is installed locally. I will take a look at the PATH. It might be because pnpm is installed in my Library folder (their new install instructions recommend that) but I really though all apps are aware of those binaries: ~/Library/pnpm/pnpm

https://pnpm.io/installation#nodejs-is-not-preinstalled

@adalinesimonian
Copy link
Member

Let me know if you run into any hurdles and I'd be happy to help investigate.

@muuvmuuv
Copy link
Author

It seems to be fixed... bit itself. Maybe it was the restart or Node update. Thanks, anyway :D sometimes things are weird

@adalinesimonian
Copy link
Member

Glad it's working for you! Feel free to open an issue if you ever run into any other trouble.

@n10l
Copy link

n10l commented Jan 16, 2022

I am getting this error as well with just npm on Mac OS. I am using node via nvm. This plugin looks broken.

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants