Closed martialanouman closed 4 months ago
Hi, Any update on this ?
Hello, any update on this, please?
I cannot reproduce this, I am using generate package successfully in my project. Check you guys are setting out path correctly
@dan-cooke can you provide the github project for us to compare? and what do you mean by "setting out path correctly">
@SirPhemmiey i cannot provide the repo as it’s private.
But I had previously experienced this error message because I was not setting the webpack plugins outputPath in my project json
I can give you an example of a working config later
@dan-cooke i would highly appreciate it, thank you.
Hi @dan-cooke , could you provide the configuration example you mentioned in your last comment?
{
"name": "api",
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "apps/api/src",
"projectType": "application",
"targets": {
"build": {
"executor": "@nx/webpack:webpack",
"options": {
"webpackConfig": "apps/api/webpack.config.js",
"outputPath": "dist/apps/api"
}
}
}
const { NxWebpackPlugin } = require('@nx/webpack');
const { join } = require('path');
module.exports = {
output: {
path: join(__dirname, '../../dist/apps/api'),
},
plugins: [
new NxWebpackPlugin({
target: 'node',
compiler: 'tsc',
main: './src/main.ts',
tsConfig: './tsconfig.app.json',
generatePackageJson: true,
transformers: [
{
name: '@nestjs/swagger/plugin',
options: {
introspectComments: true,
},
},
],
assets: ['./src/assets'],
optimization: false,
outputHashing: 'none',
}),
],
};
Works for me
I can post a min repro someday soon, but have you made sure you are not running with the nx cache? I always run my builds with --skipNxCache
because i've found it to be stale most of the time
Edit: Just realised im missing outputPath, I added that in and it still works
Node : 20.9.0
OS : linux-x64
yarn : 1.22.22
nx (global) : 18.0.8
nx : 18.0.6
@nx/js : 18.0.6
@nx/jest : 18.0.6
@nx/linter : 18.0.6
@nx/eslint : 18.0.6
@nx/workspace : 18.0.6
@nx/cypress : 18.0.6
@nx/devkit : 18.0.6
@nx/esbuild : 18.0.6
@nx/eslint-plugin : 18.0.6
@nx/nest : 18.0.6
@nx/node : 18.0.6
@nx/react : 18.0.6
@nrwl/tao : 18.0.6
@nx/vite : 18.0.6
@nx/web : 18.0.6
@nx/webpack : 18.0.6
typescript : 5.3.3
---------------------------------------
Community plugins:
@nx-extend/shadcn-ui : 1.0.0
Hi @dan-cooke, Thanks. Testing it...
I'm not sure if this helps but I ran into this issue with an application that was using TSC that was importing a SWC library with a custom executor I wrote to generate the application's package json since it couldn't use esbuild or webpack.
My executor looked like this
// The call to getHelperDependenciesFromProjectGraph was failing
const helperDependencies = getHelperDependenciesFromProjectGraph(
context.root,
context.projectName!,
context.projectGraph!
);
const packageJson = createPackageJson(context.projectName!, context.projectGraph!, {
target: context.targetName,
root: context.root,
isProduction: true,
helperDependencies: helperDependencies.map((dep) => dep.target),
});
Removing the function call getHelperDependenciesFromProjectGraph
and passing in an empty array for helperDependencies alleviated the issue for that application
This issue has been resolved and therefore I'm going to close it.
Thanks everyone for weighing in!
This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context.
Current Behavior
An error is raised when trying to build app with @nx/webpack:webpack executor while the
generatePackageJson
option is set totrue
Expected Behavior
Successful build
GitHub Repo
No response
Steps to Reproduce
project.json
: set build task executor to@nx/webpack:webpack
and set options accordinglynx build <app_name>
Nx Report
Failure Logs
Package Manager Version
pnpm@8.15.3
Operating System
Additional Information
Target config in project.json