You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[npm] Dependencies of optionalDependencies are not installed
Root Cause
Npm says dependencies of file:folder references are not installed but just symlinks to the file:folder packages are created AS DESIGNED
This behavior is different in NPM 6
Workarounds
OPTION # 1: Use npm version 6 and perform npm i twice
OPTION # 2: Use a tgz package file instead of thin-hook package on the repo as follows:
Note: This behavior may change in the future npm
cd$PROJECTDIRECTORY
rm -v thin-hook-*.tgz # clean up archives
npm pack thin-hook # create the latest archive such as thin-hook-0.4.0-alpha.57.tgz
npm i thin-hook-*.tgz # install from the tgz archive
npm i # install optionalDependencies and dependencies of the optionalDependencies
rm -v thin-hook-*.tgz # clean up archives
OPTION # 3: Install as a tgz package via package.json scripts
Notes
--save-optional avoids errors at the first installation
In postinstall script, npm i is called recursively once
{
"scripts": {
"preinstall": "if [ ! -f thin-hook-0.4.0-alpha.57.tgz ]; then npm pack [email protected]; fi",
"postinstall": "if [ ! -f node_modules/thin-hook/package.json ]; then npm i --save-optional thin-hook-0.4.0-alpha.57.tgz; npm i; else if [ ! -f node_modules/reportage/package.json ]; then npm i; fi; fi",
},
}
OPTION # 4: Copy nested plugin dependencies explicitly after npm i thin-hook@^0.4.0-alpha.57 --install-links=true
Notes:
npm i again since package-lock.json is (strangely) inconsistent after the npm i thin-hook@^0.4.0-alpha.57 --install-links=true installation
If npm i --install-links=true is executed without the explicit thin-hook package name, the plugins are unexpectedly installed at node_modules/thin-hook/node_modules/@thin-hook/* instead of the expected node_modules/@thin-hook/*, which is the reason why the explicit package name is required
There is, of course, another option that the nested dependencies are copied from node_modules/thin-hook/node_modules/@thin-hook/*/node_modules instead of node_modules/@thin-hook/*/node_modules.
As of 0.4.0-alpha.57, the plugin with any nested dependencies that have to be explicitly copied is only @thin-hook/injector-helpers
{
"scripts": {
"preinstall": "if [ ! -f node_modules/reportage/package.json ]; then npm i [email protected] --install-links=true; fi",
"install": "cd node_modules/@thin-hook/; for i in *; do { if [ -d $i/node_modules ] && [ ! -d ../thin-hook/plugins/$i/node_modules ]; then cp -rv $i/node_modules ../thin-hook/plugins/$i/; fi; } done;",
"postinstall": "grep '\"resolved\": \"file:node_modules/thin-hook/plugins/about-blank-redirector\"' package-lock.json; if [ \"$?\" = \"0\" ]; then npm i; fi",
},
"dependencies": {
"thin-hook": "0.4.0-alpha.57"
}
}
The text was updated successfully, but these errors were encountered:
[npm] Dependencies of optionalDependencies are not installed
Root Cause
file:folder
references are not installed but just symlinks to thefile:folder
packages are created AS DESIGNEDWorkarounds
npm i
twicethin-hook
package on the repo as follows:package.json
scripts--save-optional
avoids errors at the first installationpostinstall
script,npm i
is called recursively oncenpm i thin-hook@^0.4.0-alpha.57 --install-links=true
npm i
again sincepackage-lock.json
is (strangely) inconsistent after thenpm i thin-hook@^0.4.0-alpha.57 --install-links=true
installation[email protected]
npm i --install-links=true
is executed without the explicit thin-hook package name, the plugins are unexpectedly installed atnode_modules/thin-hook/node_modules/@thin-hook/*
instead of the expectednode_modules/@thin-hook/*
, which is the reason why the explicit package name is requirednode_modules/thin-hook/node_modules/@thin-hook/*/node_modules
instead ofnode_modules/@thin-hook/*/node_modules
.0.4.0-alpha.57
, the plugin with any nested dependencies that have to be explicitly copied is only@thin-hook/injector-helpers
The text was updated successfully, but these errors were encountered: