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

[BUG] Path of 3rd cli tools have invalid location under workspace #4103

Open
chinfeng opened this issue Nov 30, 2021 · 0 comments
Open

[BUG] Path of 3rd cli tools have invalid location under workspace #4103

chinfeng opened this issue Nov 30, 2021 · 0 comments
Labels
Bug thing that needs fixing Needs Triage needs review for next steps platform:windows is Windows-specific Release 8.x work is associated with a specific npm 8 release

Comments

@chinfeng
Copy link

chinfeng commented Nov 30, 2021

// package.json
{
  "private": true,
  "workspaces": ["prj"]
}
// prj/package.json
{
  "name": "@my/prj",
  "version": "0.0.1",
  "scripts": {
    "postinstall": "babel src --our-dir dest"
  }, 
   "devDependencies": {
    "@babel/cli": "^7.14.5"
  }
}
npm install

It fails in windows cause node_modules\@my\prj\node_modules\.bin\babel.cmd reference %~dp0\..\..\..\node_modules\@babel\cli\bin\babel.js. I think cli generate path relative from prj\node_modules\.bin to node_modules\@babel\cli\bin\babel.js. Bug postinstall executing under node_modules/@my/prj, so it fails:

error C:\tmp\demo\node_modules\@my\prj: Command failed.
Exit code: 1
Command: babel src
Arguments:
Directory: C:\temp\demo\node_modules\@my\prj
Output:
node:internal/modules/cjs/loader:936
  throw err;
  ^

Error: Cannot find module 'C:\temp\demo\node_modules\@my\node_modules\@babel\cli\bin\babel.js'
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
    at Function.Module._load (node:internal/modules/cjs/loader:778:27)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
    at node:internal/main/run_main_module:17:47 {
  code: 'MODULE_NOT_FOUND',
  requireStack: []
}

Expected Behavior

postinstall run after this workspace copy from prj to node_modules\@my\prj. So it should reference path relative from node_modules\@my\prj\node_modules\.bin\babel.cmd to node_modules\@babel\cli\bin\babel.js. So I can not use any "/" structure for naming package under workspaces right now.

Environment

  • npm: 8
  • Node: 16.13
  • OS: win10
@chinfeng chinfeng added Bug thing that needs fixing Needs Triage needs review for next steps Release 8.x work is associated with a specific npm 8 release labels Nov 30, 2021
@nlf nlf added the platform:windows is Windows-specific label Oct 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug thing that needs fixing Needs Triage needs review for next steps platform:windows is Windows-specific Release 8.x work is associated with a specific npm 8 release
Projects
None yet
Development

No branches or pull requests

2 participants