workspaceFileName() should return workspace.json
workspaceFileName() returns angular.json
Please provide detailed steps for reproducing the issue.
nx dep-graph
Please provide any relevant information about your setup:
nx --version
8.9.0
A minimal reproduction scenario allows us to quickly confirm a bug (or point out coding problem) as well as confirm that we are fixing the right problem.
npm install @angular/cli
nx dep-graph
Error: ENOENT: no such file or directory, open '.../angular.json'
at Object.openSync (fs.js:443:3)
at Object.readFileSync (fs.js:343:35)
at Object.readJsonFile (...node_modules\@nrwl\workspace\src\utils\fileutils.js:60:44)
at Object.readWorkspaceJson (...node_modules\@nrwl\workspace\src\command-line\shared.js:256:24)
at Object.generateGraph (...node_modules\@nrwl\workspace\src\command-line\dep-graph.js:29:36)
at Object.exports.commandsObject.yargs.usage.command.command.command.command.command.command.command.command.command.command.command.command.command.args [as handler]
This is still an issue in the latest (9.0.2).
As noted by @scallacs, it is the logic of workspaceFileName()
that needs to change.
It is using a different heuristic compared to other areas of the Nx codebase to determine the configuration file name - it is checking if @angular/cli
is present.
From my node_modules
:
function workspaceFileName() {
const packageJson = readPackageJson();
if (packageJson.devDependencies['@angular/cli'] ||
packageJson.dependencies['@angular/cli']) {
return 'angular.json';
}
else {
return 'workspace.json';
}
}
exports.workspaceFileName = workspaceFileName;
I think starting an Nx repo with a workspace.json
and then adding Angular later is a more unusual journey right now (which is why you are not hearing about this as often), but it just bit me :)
PS see you at ng-conf @FrozenPandaz!
Most helpful comment
This is still an issue in the latest (9.0.2).
As noted by @scallacs, it is the logic of
workspaceFileName()
that needs to change.It is using a different heuristic compared to other areas of the Nx codebase to determine the configuration file name - it is checking if
@angular/cli
is present.From my
node_modules
:I think starting an Nx repo with a
workspace.json
and then adding Angular later is a more unusual journey right now (which is why you are not hearing about this as often), but it just bit me :)PS see you at ng-conf @FrozenPandaz!