Open kripod opened 4 years ago
Same Error and I using: Node:12.14.0 Yarn:1.21.1 Macos 10.15.2 (19C57)
Same Error when try to execute electron-rebuild in the postinstall of a package. This only happens in windows. In Linux is working properly.
Experiencing same problem on Windows 10, with postinstall trying to find the module under \node_modules\node_modules\...
.
What is the state of this? I can't execute tsc
from postinstall
script, same error.
Hi,
I'm facing the same issue here.
Environment:
Windows 10.0.19041.508
(2004)GNU bash, version 4.4.23(1)-release (x86_64-pc-msys)
Description: I stumbled upon this after changing my package names to scoped package names (in the form @company/package).
yarn install
, one of my sub-packages (using a scoped package name) does not resolve its own dependency to tsc
properly.Trace:
[4/4] Building fresh packages...
error C:\Projects\galitt-l3-tse\node_modules\@galitt\exception: Command failed.
Exit code: 1
Command: run-s build
Arguments:
Directory: C:\Projects\galitt-l3-tse\node_modules\@galitt\exception
Output:
yarn run v1.22.5
$ echo $$NPM_EXEC_PATH && run-s build:code build:types
$$NPM_EXEC_PATH
$ echo $$NPM_EXEC_PATH && tsc
$$NPM_EXEC_PATH
internal/modules/cjs/loader.js:1033
throw err;
^
Error: Cannot find module 'C:\Projects\galitt-l3-tse\node_modules\node_modules\typescript\bin\tsc'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:1030:15)
at Function.Module._load (internal/modules/cjs/loader.js:899:27)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
at internal/main/run_main_module.js:17:47 {
code: 'MODULE_NOT_FOUND',
requireStack: []
}
error Command failed with exit code 1.
Some more details:
I noticed wrappers to tsc seems to have been created inside the sub-package's node_modules by yarn install
.
Contents of /c/Projects/galitt-l3-tse/node_modules/@galitt/exception/node_modules/.bin/tsc
below:
#!/bin/sh
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
case `uname` in
*CYGWIN*) basedir=`cygpath -w "$basedir"`;;
esac
if [ -x "$basedir/node" ]; then
"$basedir/node" "$basedir/../../../../typescript/bin/tsc" "$@"
ret=$?
else
node "$basedir/../../../../typescript/bin/tsc" "$@"
ret=$?
fi
exit $ret
It seems that the path %~dp0\..\..\..\..\
resolves to the root node_modules folder, and the wrapper script is appending node_modules to it.
Hence we lookup for the binary inside ...\node_modules\node_modules\...
instead of ...\node_modules\...
One can notice there is also a windows shell script named tsc.cmd that follows the same (flawed ?) logic.
Fun fact:
When I cd
into /c/Projects/galitt-l3-tse/node_modules/@galitt/exception
and execute yarn postinstall
manually, it works just fine.
Question: Does somebody have any idea how those wrappers are generated ? And if it is possible how to fix them so they can properly implement the node module resolution algorithm by recursively looking upwards ?
Same issue here, it is trying to resolve to root\node_modules\node_modules\package
instead of root\node_modules\package
.
Windows 10 Node 12.0.0 npm 6.9.0 yarn 1.22.10
Putting the postinstall
scripts at the root package.json
solved the issue for me, but ideally, I would want them localized.
I have the same problem, but trying to postinstall in my monorepo Husky o Lefthook in windows with yarn 1.22.22
Do you want to request a feature or report a bug?
I'm reporting a bug.
If the current behavior is a bug, please provide the steps to reproduce.
When using Yarn workspaces with the configuration below:
The
postinstall
script insideserver/package.json
cannot run properly. It tries to invoke a binary of its own dependency, as seen below:And the following error gets thrown when executing
yarn
from the root directory:As it can be seen, it tries to invoke
D:\Development\Projects\app\node_modules\node_modules\prisma2\build\index.js
, which does not exist. When runningyarn
from the 'server' directory, everything works as expected.I think that before executing
postinstall
scripts for each package, the current directory should be modified to simulate execution straight from the package instead of the workspace root.Please mention your node.js, yarn and operating system version.
Node.js: 12.11.1 Yarn: 1.19.1 Windows 10 x64