A problem similar to, but not identical with,
Getting this today in an Azure Devops pipeline on ubuntu, works locally with the same versions but on Windows, my versions are:
- ng 14.2.0
- node 16.15.0
- eslint 14.1.2
Message is
Failed to load plugin ‘@angular-eslint/template’ declared in ‘.eslintrc.json#overrides[0]’: Cannot find module ‘functions-have-names’
Full output:
Starting: Linting
==============================================================================
Task : Command line
Description : Run a command line script using Bash on Linux and macOS and cmd.exe on Windows
Version : 2.212.0
Author : Microsoft Corporation
Help : https://docs.microsoft.com/azure/devops/pipelines/tasks/utility/command-line
==============================================================================
Generating script.
========================== Starting Command Output ===========================
/usr/bin/bash --noprofile --norc /azp/_work/_temp/ee65254e-8ae2-489b-af62-a95cb725b90c.sh
Linting "caats-pwa"...
An unhandled exception occurred: Failed to load plugin '@angular-eslint/template' declared in '.eslintrc.json#overrides[0]': Cannot find module 'functions-have-names'
Require stack:
- /azp/_work/1/s/node_modules/set-function-name/index.js
- /azp/_work/1/s/node_modules/regexp.prototype.flags/implementation.js
- /azp/_work/1/s/node_modules/regexp.prototype.flags/index.js
- /azp/_work/1/s/node_modules/deep-equal/index.js
- /azp/_work/1/s/node_modules/aria-query/lib/elementRoleMap.js
- /azp/_work/1/s/node_modules/aria-query/lib/index.js
- /azp/_work/1/s/node_modules/@angular-eslint/eslint-plugin-template/dist/index.js
- /azp/_work/1/s/node_modules/@eslint/eslintrc/dist/eslintrc.cjs
Referenced from: /azp/_work/1/s/.eslintrc.json
See "/tmp/ng-54uHxa/angular-errors.log" for further details.
##[error]Bash exited with code '1'.
Finishing: Linting
There is no change in any parts of the build configuration from our side whatsoever, the only thing I can think of is somewhere the build system pulling something that is "latest" (the OS itself?). We pinned ng, node and eslint already to the versions mentioned above.
Pipeline script task (Microsoft Azure Devops yml):
pool:
name: Default
vmImage: ubuntu-latest
steps:
- task: NodeTool@0
inputs:
versionSpec: '16.15.0'
displayName: 'Node.js installation'
- script: |
npm install --location=project --force @angular/cli@~14.2.0
displayName: 'Install Angular'
- script: |
npm install --force
displayName: 'Dependencies'
- script: |
npx ng lint
if [ $? -ne 0 ]; then
exit 1
fi
displayName: 'Linting'
What can be the reason for this pipline-only failure in the linting step, and how to solve?
Edit additional information: We started the same pipeline from a known-good recent release tag, same error. same versions. So it must be related to the build environment somehow, and a code or script change can be ruled out. What do I do to diagnose this? Reverting the OS to a previous version is maybe worth a try, but not a viable solution. We are on a self-hosted build machine.
2
Answers
1. Check Your ESLint Configuration: Take a look at your ESLint configuration file,
.eslintrc.json
. Make sureyou’ve got the
'functions-have-names'
plugin set up correctly in the pluginssection. It’s essential to double-check the paths and versions you’ve
specified there.
2. Dependency Versions: Ensure that the versions of ESLint and its related plugins in your
package.json
file match the versions you’re using locally, where everything works. You can use thenpm ls
command to investigate if there are any issues with your project’s dependencies.3. Clear npm Cache: Sometimes, npm caches can get in the way. You can try clearing the npm cache by running
npm cache clean -f
.4. Reinstall Dependencies: After clearing the cache, get rid of the
node_modules
folder andpackage-lock.json
file. Then, reinstall your project’s dependencies withnpm install
.5. Update Node.js: Verify that Node.js version
16.15.0
is compatible with the packages you’re using. Consider updating Node.js to a newer LTS version if needed.6. Check for Environment Differences: Since things work locally but not in the pipeline, it’s worth investigating any differences in the pipeline’s environment. Make sure your pipeline setup is correct and isn’t conflicting with global ESLint or Node.js installations.
7. Verify Plugin Installation: Make sure the
'functions-have-names'
plugin is indeed installed in your project. You can peek inside thenode_modules
folder to see if it’s there.8. Review Recent Changes: If the pipeline used to work fine and suddenly broke, go over any recent changes you made to your code, ESLint configuration, or package versions. This could help pinpoint what triggered the problem.
9. Azure DevOps Cache: If Azure DevOps is caching dependencies, try clearing or turning off the cache to ensure you’re working with a clean slate in your pipeline.
10. Contact Azure DevOps Support: If none of the above steps do the trick, don’t hesitate to reach out to Azure DevOps support. They might have insights into any platform-related issues that could be causing the problem.
I hope these steps help you get to the bottom of the issue
Quickfix: just add "functions-have-names": "1.2.3" do your devDependencies
from: https://github.com/angular-eslint/angular-eslint/issues/1522