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

Salesforce CLI link plugin issue #2915

Closed
JaniszewskiMarcin opened this issue Jun 12, 2024 · 12 comments
Closed

Salesforce CLI link plugin issue #2915

JaniszewskiMarcin opened this issue Jun 12, 2024 · 12 comments
Labels
more information required Issue requires more information or a response from the customer stale

Comments

@JaniszewskiMarcin
Copy link

Summary

When updating CLI version to the latest one we can not link plugins.
Error message:
"@salesforce/cli: Linking plugin ../pluginName... !
› Error: /usr/local/lib/node_modules/@salesforce/cli/node_modules/npm/bin/np
› m-cli.js install --no-audit --loglevel=silent --no-fund exited with code 2
› Try this: Run with DEBUG=@oclif/plugin-plugins* to see debug output."

We start to observe this errors happening from version 2.35.6 (April 3, 2024) and even now the newest version 2.44.8 (Jun 5, 2024) [stable] still causes same issues.

Steps To Reproduce

  1. Update CLI version to the newest one for now 2.44.8 (Jun 5, 2024).
  2. Try to link plugin from your local device.

Expected result

Proper plugin linking.

Actual result

Plugin is not linked and can not be use in other parts of script.

System Information

  • Terminal Powershell
  • Command: sf plugins link "pluginName"

Additional information

No additional information.

@JaniszewskiMarcin JaniszewskiMarcin added the investigating We're actively investigating this issue label Jun 12, 2024
Copy link

Hello @JaniszewskiMarcin 👋 It looks like you didn't include the full Salesforce CLI version information in your issue.
Please provide the output of version --verbose --json for the CLI you're using (sf or sfdx).

A few more things to check:

  • Make sure you've provided detailed steps to reproduce your issue.
    • A repository that clearly demonstrates the bug is ideal.
  • Make sure you've installed the latest version of Salesforce CLI. (docs)
    • Better yet, try the rc or nightly versions. (docs)
  • Try running the doctor command to diagnose common issues.
  • Search GitHub for existing related issues.

Thank you!

@github-actions github-actions bot added more information required Issue requires more information or a response from the customer and removed investigating We're actively investigating this issue labels Jun 12, 2024
Copy link

Thank you for filing this issue. We appreciate your feedback and will review the issue as soon as possible. Remember, however, that GitHub isn't a mechanism for receiving support under any agreement or SLA. If you require immediate assistance, contact Salesforce Customer Support.

@cristiand391
Copy link
Member

could you run the command with this env var set and share the output?
DEBUG=@oclif/plugin-plugins*

@JaniszewskiMarcin
Copy link
Author

JaniszewskiMarcin commented Jun 12, 2024

Below you can find an output:

(node:32552) [DEP0040] DeprecationWarning: The punycode module is deprecated. Please use a userland alternative instead.
(Use node --trace-deprecation ... to show where the warning was created)
@oclif/plugin-plugins installing dependencies with npm +0ms
@oclif/plugin-plugins:npm npm binary path C:\Users\marcin.janiszewski\AppData\Roaming\npm\node_modules@salesforce\cli\node_modules\npm\bin\npm-cli.js +0ms
@oclif/plugin-plugins:npm C:\Users\marcin.janiszewski\Desktop\Repositories\sfdx-project: C:\Users\marcin.janiszewski\AppData\Roaming\npm\node_modules@salesforce\cli\node_modules\npm\bin\npm-cli.js install --no-audit --loglevel=silent --no-fund +0ms
@oclif/plugin-plugins:spawn modulePath node +0ms
@oclif/plugin-plugins:spawn args [
'"C:\Users\marcin.janiszewski\AppData\Roaming\npm\node_modules\@salesforce\cli\node_modules\npm\bin\npm-cli.js"',
'install',
'--no-audit',
'--loglevel=silent',
'--no-fund'
] +0ms
@oclif/plugin-plugins:spawn node_modules/@salesforce/core/lib/org/authInfo.d.ts(3,10): error TS2724: '"jsforce"' has no exported member named 'JwtOAuth2Config'. Did you mean 'OAuth2Config'? +8s
@oclif/plugin-plugins:spawn node_modules/@salesforce/core/lib/webOAuthServer.d.ts(3,10): error TS2724: '"jsforce"' has no exported member named 'JwtOAuth2Config'. Did you mean 'OAuth2Config'? +0ms
@oclif/plugin-plugins:npm npm error CLIError: node "C:\Users\marcin.janiszewski\AppData\Roaming\npm\node_modules@salesforce\cli\node_modules\npm\bin\npm-cli.js" install --no-audit --loglevel=silent --no-fund exited with code 2
at ChildProcess. (file:///C:/Users/marcin.janiszewski/AppData/Roaming/npm/node_modules/@salesforce/cli/node_modules/@oclif/plugin-plugins/lib/spawn.js:70:24)
at ChildProcess.emit (node:events:515:28)
at ChildProcess.emit (node:domain:488:12)
at Process.ChildProcess._handle.onexit (node:internal/child_process:294:12) {
code: undefined,
oclif: { exit: 2 },
skipOclifErrorHandling: undefined,
suggestions: [ 'Run with DEBUG=@oclif/plugin-plugins* to see debug output.' ]
} +8s
@salesforce/cli: Linking plugin ../sfdx-project... !
» Error: node "C:\Users\marcin.janiszewski\AppData\Roaming\npm\node_modules@salesforce\cli\node_modules\npm\bin\npm-cli.js" install --no-audit --loglevel=silent --no-fund exited with code 2
» Try this: Run with DEBUG=@oclif/plugin-plugins* to see debug output.

@cristiand391
Copy link
Member

That's a typescript error but sf plugins link doesn't build your plugin when you link it 🤔

could it be that you have a postinstall script in your plugin that tries to build it? if so, you might need to fix the error in your plugin first.

@JaniszewskiMarcin
Copy link
Author

Ticket to be closed indeed there was deprecated member named 'JwtOAuth2Config' should be 'OAuth2Config' in my scripts. Main issue was that in Visual Studio Code search function do not scan all the files and I assumed we do not have any of those variables or at least not on our side. Thanks for help!

@JaniszewskiMarcin
Copy link
Author

Since problem is resolved I'am closing the issue.

@JaniszewskiMarcin
Copy link
Author

Hello,
So changing that deprecated member named 'JwtOAuth2Config' to 'OAuth2Config' in my scripts made it work but when I try to apply this to pipelines and we do not store node_modules in repository since our machines install everything on run from scratch so I have to somehow fix it that 'npm install' will install everything as it should be.

So now to be clear what is happening inside my plugin here is package.json content:
"dependencies": { "@oclif/command": "^1", "@oclif/config": "^1", "@oclif/errors": "^1", "@salesforce/command": "^5", "@salesforce/core": "^3", "archiver": "^5.3.1", "axios": "^1.2.2", "fast-xml-parser": "4.0.12", "tslib": "^2" }, "devDependencies": { "@oclif/dev-cli": "^1", "@oclif/plugin-help": "^5", "@oclif/test": "^2", "@salesforce/dev-config": "^3", "@salesforce/dev-scripts": "^3", "@salesforce/prettier-config": "^0", "@salesforce/ts-sinon": "^1", "@types/archiver": "^5.3.1", "@types/chai": "^4", "@types/mocha": "^10", "@types/node": "^18.11.18", "@types/rimraf": "^3.0.2", "@typescript-eslint/eslint-plugin": "^5.48.0", "@typescript-eslint/parser": "^5", "chai": "^4", "eslint": "^8.31.0", "eslint-config-oclif": "^4.0", "eslint-config-prettier": "^8", "eslint-config-salesforce": "^1", "eslint-config-salesforce-typescript": "^1", "eslint-plugin-header": "^3", "eslint-plugin-import": "^2", "eslint-plugin-jsdoc": "^39", "eslint-plugin-prettier": "^4", "globby": "^11", "husky": "^8", "mocha": "^10", "nyc": "^15", "prettier": "^2", "rimraf": "^3.0.2", "sinon": "15.0.1", "ts-node": "^10", "typescript": "4" }, "engines": { "node": ">=18.0.0" }

In post-install I have command "tsc -p ." that throws the main errors:

  • node_modules/@salesforce/core/lib/webOAuthServer.d.ts:3:10 - error TS2724: '"jsforce"' has no exported member named 'JwtOAuth2Config'. Did you mean 'OAuth2Config'?
  • node_modules/@salesforce/core/lib/webOAuthServer.d.ts:3:10 - error TS2724: '"jsforce"' has no exported member named 'JwtOAuth2Config'. Did you mean 'OAuth2Config'?

My file with tsconfig.json:
{ "extends": "@salesforce/dev-config/tsconfig", "compilerOptions": { "outDir": "lib", "rootDir": "src", "esModuleInterop": true, "resolveJsonModule": true, }, "include": [ "./src/**/*.ts" ] }

So now somehow I have to fix dependencies in package.json or tsconfig.json to make it work only from running "npm i" and I can not understand why something in @salesforce/core package in node_modules which installed automatically is working in a wrong way and trying to reference member of library that is deprecated? Any ideas?

@mshanemc
Copy link
Contributor

can you share your plugin code? Or the scripts that you're using? I'm trying to understand what's referring toJwtOAuth2Config

@JaniszewskiMarcin
Copy link
Author

For plugin we only use import { Messages } from '@salesforce/core'; in typeScript files. That error is happening when trying to compile files in plugin in typeScript to .js with command "tsc -p ." even If I added to tsconfig.json to exclude folder "node_modules". The error is clearly in those two files:

  • node_modules/@salesforce/core/lib/webOAuthServer.d.ts
  • node_modules/@salesforce/core/lib/webOAuthServer.d.ts

Bu then I can not understand why it is not fixed in @salesforce/core that it try to use deprecated 'JwtOAuth2Config' or is it somehow our plugin side but we do not even once use any of those statements only "{ Messages } from '@salesforce/core';".

Copy link

This issue has not received a response in 7 days. It will auto-close in 7 days unless a response is posted.

@github-actions github-actions bot added the stale label Jul 24, 2024
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Aug 1, 2024
@RupertBarrow
Copy link

Hey @JaniszewskiMarcin , maybe adding package-lock.json to your repository could help. npm install will use its contents.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
more information required Issue requires more information or a response from the customer stale
Projects
None yet
Development

No branches or pull requests

4 participants