frontend-maven-plugin icon indicating copy to clipboard operation
frontend-maven-plugin copied to clipboard

Can't run cross-env if node package name is in the format "@namespace/packagename"

Open alex-dow opened this issue 3 years ago • 0 comments

Do you want to request a feature or report a bug?

bug

What is the current behavior?

In a yarn v1 workspace, my packages are named @test/app1 and @test/app2 . @test/app1 has a postinstall script that is invoked like so:

cross-env ELECTRON_RUN_AS_NODE=1 npx --no-install electron ./postinstall.js

It fails like so:

[INFO] error C:\Users\adowgail\Documents\frontend-maven-plugin-issue\node_modules\@test\app1: Command failed.info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
[INFO] Exit code: 1
[INFO] Command: cross-env ELECTRON_RUN_AS_NODE=1 npx --no-install electron ./postinstall.js
[INFO] Arguments:
[INFO] Directory: C:\Users\adowgail\Documents\frontend-maven-plugin-issue\node_modules\@test\app1
[INFO] Output:
[INFO] node:internal/modules/cjs/loader:936
[INFO]   throw err;
[INFO]   ^
[INFO]
[INFO] Error: Cannot find module 'C:\Users\adowgail\Documents\frontend-maven-plugin-issue\node_modules\node_modules\cross-env\src\bin\cross-env.js'
[INFO]     at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
[INFO]     at Function.Module._load (node:internal/modules/cjs/loader:778:27)
[INFO]     at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12)
[INFO]     at node:internal/main/run_main_module:17:47 {
[INFO]   code: 'MODULE_NOT_FOUND',
[INFO]   requireStack: []
[INFO] }

Note the folder problem: node_modules\node_modules\cross-env\src\bin\cross-env.js

If you remove the @test/ prefix from the package names, then mvn install works fine.

If the current behavior is a bug, please provide the steps to reproduce.

https://github.com/alex-dow/frontend-maven-plugin-issue - clone this repo and run mvn install

What is the expected behavior?

mvn install should work without issue in the above repo

Please mention your frontend-maven-plugin and operating system version.

frontend-maven-plugin: 1.12.1 windows 10

alex-dow avatar Jul 29 '22 15:07 alex-dow