-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Description
[npm] Dependencies of optionalDependencies are not installed
Root Cause
- Npm says dependencies of
file:folderreferences are not installed but just symlinks to thefile:folderpackages are created AS DESIGNED - This behavior is different in NPM 6
Workarounds
- OPTION # 1: Use npm version 6 and perform
npm itwice - OPTION # 2: Use a tgz package file instead of
thin-hookpackage 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.jsonscripts- Notes
--save-optionalavoids errors at the first installation- In
postinstallscript,npm iis called recursively once
- Notes
{
"scripts": {
"preinstall": "if [ ! -f thin-hook-0.4.0-alpha.57.tgz ]; then npm pack thin-hook@0.4.0-alpha.57; 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 iagain sincepackage-lock.jsonis (strangely) inconsistent after thenpm i thin-hook@^0.4.0-alpha.57 --install-links=trueinstallation- Verified with
npm@9.8.1 - If
npm i --install-links=trueis 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 required - There is, of course, another option that the nested dependencies are copied from
node_modules/thin-hook/node_modules/@thin-hook/*/node_modulesinstead ofnode_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
- Notes:
{
"scripts": {
"preinstall": "if [ ! -f node_modules/reportage/package.json ]; then npm i thin-hook@0.4.0-alpha.57 --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"
}
}Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels