forcedotcom / salesforcedx-vscode

Salesforce Extensions for VS Code
https://developer.salesforce.com/tools/vscode
BSD 3-Clause "New" or "Revised" License
954 stars 406 forks source link

npm errors out when trying to install the packages in the standard SFDX project #3030

Closed chivalry closed 3 years ago

chivalry commented 3 years ago

Summary

Creating a project with the SFDX integration, attempting to install the dependences in the generated package.json results in an error.

Steps To Reproduce:

  1. Open a new window in VS Code.
  2. Access the Command Pallet and execute SFDX: Create Project.
  3. Select standard, give it a name, and select a folder.
  4. Open a terminal and execute npm install.

Expected result

I would expect that npm would install the packages listed in package.json.

Actual result

I got the following output:

npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR! 
npm ERR! While resolving: salesforce-app@1.0.0
npm ERR! Found: eslint@7.21.0
npm ERR! node_modules/eslint
npm ERR!   dev eslint@"^7.6.0" from the root project
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! peer eslint@"^6.0.0" from @salesforce/eslint-config-lwc@0.7.0
npm ERR! node_modules/@salesforce/eslint-config-lwc
npm ERR!   dev @salesforce/eslint-config-lwc@"^0.7.0" from the root project
npm ERR! 
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR! 
npm ERR! See /Users/chuck/.npm/eresolve-report.txt for a full report.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/chuck/.npm/_logs/2021-03-06T16_32_48_395Z-debug.log

Additional information

I'm rather new to this entire environment of Salesforce DX, Node, etc., so my guess is that if I knew more about what I was doing, the error information above and the disparate versions of node and npm would be sufficient for me to fix the problem, but I don't even know why there are three different versions of node (the VS Code version, the SFDX CLI version and the version reported in the terminal). I'm guessing that has something to do with it.

VS Code Version:

Version: 1.54.0 Commit: 42e27fe5cdc58539dad9867970326a297eb8cacf Date: 2021-03-03T02:17:59.499Z Electron: 11.3.0 Chrome: 87.0.4280.141 Node.js: 12.18.3 V8: 8.7.220.31-electron.0 OS: Darwin x64 19.6.0

SFDX CLI Version: sfdx-cli/7.88.4-3b2e55c3f1 darwin-x64 node-v14.15.4

OS and version: macOS 10.15.7

node version: (output of node --version in terminal) 15.0.1

npm version: (output of npm --version in terminal) 7.0.3

lcampos commented 3 years ago

Hi @chivalry , could you share the package.json file you are using ? I haven't been able to replicate this with the same Node & NPM versions you are on.

chivalry commented 3 years ago

I just happened to have just created a new project and confirmed the above output when attempting to run npm install. This is the package.json that "SFDX: Create Project" generated:

{
  "name": "salesforce-app",
  "private": true,
  "version": "1.0.0",
  "description": "Salesforce App",
  "scripts": {
    "lint": "npm run lint:lwc && npm run lint:aura",
    "lint:aura": "eslint **/aura/**",
    "lint:lwc": "eslint **/lwc/**",
    "test": "npm run test:unit",
    "test:unit": "sfdx-lwc-jest",
    "test:unit:watch": "sfdx-lwc-jest --watch",
    "test:unit:debug": "sfdx-lwc-jest --debug",
    "test:unit:coverage": "sfdx-lwc-jest --coverage",
    "prettier": "prettier --write \"**/*.{cls,cmp,component,css,html,js,json,md,page,trigger,xml,yaml,yml}\"",
    "prettier:verify": "prettier --list-different \"**/*.{cls,cmp,component,css,html,js,json,md,page,trigger,xml,yaml,yml}\""
  },
  "devDependencies": {
    "@prettier/plugin-xml": "^0.12.0",
    "@salesforce/eslint-config-lwc": "^0.7.0",
    "@salesforce/eslint-plugin-aura": "^1.4.0",
    "@salesforce/sfdx-lwc-jest": "^0.9.2",
    "eslint": "^7.6.0",
    "eslint-config-prettier": "^6.11.0",
    "husky": "^4.2.1",
    "lint-staged": "^10.0.7",
    "prettier": "^2.0.5",
    "prettier-plugin-apex": "^1.6.0"
  },
  "husky": {
    "hooks": {
      "pre-commit": "lint-staged"
    }
  },
  "lint-staged": {
    "**/*.{cls,cmp,component,css,html,js,json,md,page,trigger,xml,yaml,yml}": [
      "prettier --write"
    ],
    "**/{aura|lwc}/**": [
      "eslint"
    ]
  }
}

Note that I can get around this with npm install --force, but I don't know if I should do that.

lcampos commented 3 years ago

Thanks, I can confirm I'm using the same package.json configs. I can think of a couple of things that can cause what you are running into. The first is that you might have globally installed a dependency that conflicts with some of the dependencies in this project. You can check for that by running npm list -g.

If that's not the case, then you might have a conflicting copy of a dependency in your npm's cache. You can clear your npm cache or run npm install --force should be ok since it only forces npm to download the dependencies even when you might have a local copy of them.

chivalry commented 3 years ago
/usr/local/lib
├── create-react-app@3.4.1
├── express-generator@4.16.1
├── jest@26.6.1
├── knex@0.21.12
├── learnyounode@4.2.2
├── node-red@1.1.3
├── npm@7.0.3
├── sequelize-cli@6.2.0
├── typeorm@0.2.29
└── yarn@1.22.4

I npm uninstall -ged on all of them except npm and node-red and the error still happened. npm list -g confirmed that those were the only two left:

/usr/local/lib
├── node-red@1.1.3
└── npm@7.0.3

I then ran npm install npm@latest -g and that upgraded me to version 7.6.1. But npm install still errors out. I finally ran npm uninstall node-red -g and that did give an error about an inability to delete a directory, which I deleted manually with sudo rm -rf .... But even then, with only npm installed globally, the command errors out.

BTW, early in the process, I also ran npm cache clean --force.

So I don't know what could be causing this. I hope it'll be fixed when I some day do that clean install of Big Sur that I've been planning, but in the meantime, I'll run npm install --force.

chivalry commented 3 years ago

In case it helps figure out the source of the problem, here's the output of npm install --force.

npm WARN using --force Recommended protections disabled.
npm WARN ERESOLVE overriding peer dependency
npm WARN Found: eslint@7.21.0
npm WARN node_modules/eslint
npm WARN   dev eslint@"^7.6.0" from the root project
npm WARN 
npm WARN Could not resolve dependency:
npm WARN peer eslint@"^6.0.0" from @salesforce/eslint-config-lwc@0.7.0
npm WARN node_modules/@salesforce/eslint-config-lwc
npm WARN   dev @salesforce/eslint-config-lwc@"^0.7.0" from the root project
npm WARN ERESOLVE overriding peer dependency
npm WARN Found: eslint@7.21.0
npm WARN node_modules/eslint
npm WARN   dev eslint@"^7.6.0" from the root project
npm WARN 
npm WARN Could not resolve dependency:
npm WARN peer eslint@"2.x - 6.x" from eslint-plugin-import@2.20.2
npm WARN node_modules/@salesforce/eslint-config-lwc/node_modules/eslint-plugin-import
npm WARN   eslint-plugin-import@"~2.20.2" from @salesforce/eslint-config-lwc@0.7.0
npm WARN   node_modules/@salesforce/eslint-config-lwc
npm WARN ERESOLVE overriding peer dependency
npm WARN Found: eslint@7.21.0
npm WARN node_modules/eslint
npm WARN   dev eslint@"^7.6.0" from the root project
npm WARN 
npm WARN Could not resolve dependency:
npm WARN peer eslint@"2.x - 6.x" from eslint-plugin-import@2.20.2
npm WARN node_modules/@salesforce/eslint-config-lwc/node_modules/eslint-plugin-import
npm WARN   eslint-plugin-import@"~2.20.2" from @salesforce/eslint-config-lwc@0.7.0
npm WARN   node_modules/@salesforce/eslint-config-lwc
npm WARN ERESOLVE overriding peer dependency
npm WARN Found: eslint@7.21.0
npm WARN node_modules/eslint
npm WARN   dev eslint@"^7.6.0" from the root project
npm WARN 
npm WARN Could not resolve dependency:
npm WARN peer eslint@"^3.0.0 || ^4.0.0 || ^5.0.0 || ^6.0.0" from eslint-plugin-compat@3.3.0
npm WARN node_modules/@salesforce/eslint-plugin-aura/node_modules/eslint-plugin-compat
npm WARN   eslint-plugin-compat@"3.3.0" from @salesforce/eslint-plugin-aura@1.4.0
npm WARN   node_modules/@salesforce/eslint-plugin-aura
npm WARN ERESOLVE overriding peer dependency
npm WARN Found: eslint@7.21.0
npm WARN node_modules/eslint
npm WARN   dev eslint@"^7.6.0" from the root project
npm WARN 
npm WARN Could not resolve dependency:
npm WARN peer eslint@"^3.0.0 || ^4.0.0 || ^5.0.0 || ^6.0.0" from eslint-plugin-compat@3.3.0
npm WARN node_modules/@salesforce/eslint-plugin-aura/node_modules/eslint-plugin-compat
npm WARN   eslint-plugin-compat@"3.3.0" from @salesforce/eslint-plugin-aura@1.4.0
npm WARN   node_modules/@salesforce/eslint-plugin-aura
npm WARN deprecated request-promise-native@1.0.9: request-promise-native has been deprecated because it extends the now deprecated request package, see https://github.com/request/request/issues/3142
npm WARN deprecated urix@0.1.0: Please see https://github.com/lydell/urix#deprecated
npm WARN deprecated har-validator@5.1.5: this library is no longer supported
npm WARN deprecated resolve-url@0.2.1: https://github.com/lydell/resolve-url#deprecated
npm WARN deprecated fsevents@1.2.13: fsevents 1 will break on node v14+ and could be using insecure binaries. Upgrade to fsevents 2.
npm WARN deprecated babel-eslint@10.1.0: babel-eslint is now @babel/eslint-parser. This package will no longer receive updates.
npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
npm WARN deprecated mdn-browser-compat-data@0.0.84: mdn-browser-compat-data is deprecated. Upgrade to @mdn/browser-compat-data. Learn more: https://github.com/mdn/browser-compat-data/blob/v1.1.2/UPGRADE-2.0.x.md

added 1097 packages, and audited 1098 packages in 43s

79 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities
smaddox-sf commented 3 years ago

Hi @chivalry - I'm glad you are unblocked