Closed JoshuaToth closed 11 months ago
Hi Josh - you will need to be careful when naming your local workspace dependencies as frontend
will actually resolve to: https://www.npmjs.com/package/frontend. The reason this occurs is that when the package.json is synthed, it will create a dependency like: frontend:"*"
which will resolve to the actual frontend
npm package given that is currently at a 2.x release. For most cases (where th published npm package is in the 1.x range), if your name conflicts with an npm package it will use your local dependency however in this case given frontend
is in the 2.x range, that is preferred. We could potentially make a change to ensure local dependencies are resolved via workspace:*
, however this is only supported in pnpm
and bun
so would still be problematic for yarn/npm
.
The recommendation is to always scope your workspace packages to prevent conflicts with the public registry.
oh damn, well yeah fair enough
Describe the bug
If the package name property of a CloudscapeReactTsWebsiteProject construct is 'frontend' and the project is then included on the InfrastructureTsProject as the
cloudscapeReactTsWebsite
the pdk command will fail with a build error around node-gyp, with its libraries not being properly generated (or truncated?).The package name seems to be fine for anything else I've tried. 'website' (default), 'bar', 'pdkisawesome' etc.
The
outdir
doesn't seem to have anything to do with it, and can be 'frontend' or whatever with no issue.Initially you get an error about python2 not being available in the shell as a command. Adding in python2 as a command through pyenv results in the truncated node-gyp library (tested in node 18 and 20).
These issues don't occur with any other package name.
Expected Behavior
That package name doesn't cause an error with the pdk command.
Current Behavior
Error without python2
```zsh .../node_modules/node-sass postinstall$ node scripts/build.js │ Building: /Users/joshtoth/.nvm/versions/node/v20.5.0/bin/node /Users/joshtoth/dev/project_dir/node_modules/.… │ gyp info it worked if it ends with ok │ gyp verb cli [ │ gyp verb cli '/Users/joshtoth/.nvm/versions/node/v20.5.0/bin/node', │ gyp verb cli '/Users/joshtoth/dev/project_dir/node_modules/.pnpm/node-gyp@3.8.0/node_modules/node-gyp/bin/… │ gyp verb cli 'rebuild', │ gyp verb cli '--verbose', │ gyp verb cli '--libsass_ext=', │ gyp verb cli '--libsass_cflags=', │ gyp verb cli '--libsass_ldflags=', │ gyp verb cli '--libsass_library=' │ gyp verb cli ] │ gyp info using node-gyp@3.8.0 │ gyp info using node@20.5.0 | darwin | arm64 │ gyp verb command rebuild [] │ gyp verb command clean [] │ gyp verb clean removing "build" directory │ gyp verb command configure [] │ gyp verb check python checking for Python executable "python2" in the PATH │ gyp verb `which` succeeded python2 /Users/joshtoth/.pyenv/shims/python2 │ gyp ERR! configure error │ gyp ERR! stack Error: Command failed: /Users/joshtoth/.pyenv/shims/python2 -c import sys; print "%s.%s.%s" % sys.ve… │ gyp ERR! stack pyenv: python2: command not found │ gyp ERR! stack │ gyp ERR! stack The `python2' command exists in these Python versions: │ gyp ERR! stack 2.7.18 │ gyp ERR! stack │ gyp ERR! stack Note: See 'pyenv help global' for tips on allowing both │ gyp ERR! stack python2 and python3 to be found. │ gyp ERR! stack │ gyp ERR! stack at ChildProcess.exithandler (node:child_process:421:12) │ gyp ERR! stack at ChildProcess.emit (node:events:514:28) │ gyp ERR! stack at maybeClose (node:internal/child_process:1105:16) │ gyp ERR! stack at ChildProcess._handle.onexit (node:internal/child_process:305:5) │ gyp ERR! System Darwin 22.6.0 │ gyp ERR! command "/Users/joshtoth/.nvm/versions/node/v20.5.0/bin/node" "/Users/joshtoth/dev/project_dir/node… │ gyp ERR! cwd /Users/joshtoth/dev/project_dir/node_modules/.pnpm/node-sass@4.14.1/node_modules/node-sass │ gyp ERR! node -v v20.5.0 │ gyp ERR! node-gyp -v v3.8.0 │ gyp ERR! not ok │ Build failed with error code: 1 └─ Failed in 734ms at /Users/joshtoth/dev/project_dir/node_modules/.pnpm/node-sass@4.14.1/node_modules/node-sass ELIFECYCLE Command failed with exit code 1. /Users/joshtoth/dev/project_dir/node_modules/.pnpm/projen@0.77.1_constructs@10.3.0/node_modules/projen/src/task-runtime.ts:204 throw new Error( ^ Error: Task "install" failed when executing "pnpm i --no-frozen-lockfile" (cwd: /Users/joshtoth/dev/project_dir) at new RunTask (/Users/joshtoth/dev/project_dir/node_modules/.pnpm/projen@0.77.1_constructs@10.3.0/node_modules/projen/src/task-runtime.ts:204:17) at TaskRuntime.runTask (/Users/joshtoth/dev/project_dir/node_modules/.pnpm/projen@0.77.1_constructs@10.3.0/node_modules/projen/src/task-runtime.ts:76:5) at NodePackage.installDependencies (/Users/joshtoth/dev/project_dir/node_modules/.pnpm/projen@0.77.1_constructs@10.3.0/node_modules/projen/src/javascript/node-package.ts:1502:13) at NodePackage.postSynthesize (/Users/joshtoth/dev/project_dir/node_modules/.pnpm/projen@0.77.1_constructs@10.3.0/node_modules/projen/src/javascript/node-package.ts:866:12) at MonorepoTsProject.synth (/Users/joshtoth/dev/project_dir/node_modules/.pnpm/projen@0.77.1_constructs@10.3.0/node_modules/projen/src/project.ts:618:14) at MonorepoTsProject.synth (/Users/joshtoth/dev/project_dir/node_modules/.pnpm/@aws+pdk@0.22.42_@aws-cdk+aws-cognito-identitypool-alpha@2.110.1-alpha.0_@pnpm+logger@5.0.0_@_xbq6lcvsguulglgpaubb2xhoey/node_modules/@aws/pdk/monorepo/projects/typescript/monorepo-ts.ts:545:11) at Object.Error with python2
```zsh Progress: resolved 2395, reused 2366, downloaded 0, added 0, done node_modules/.pnpm/fsevents@1.2.13/node_modules/fsevents: Running install script, done in 5.2s node_modules/.pnpm/core-js@3.33.3/node_modules/core-js: Running postinstall script, done in 72ms node_modules/.pnpm/core-js-pure@3.33.3/node_modules/core-js-pure: Running postinstall script, done in 73ms node_modules/.pnpm/node-sass@4.14.1/node_modules/node-sass: Running install script, done in 709ms node_modules/.pnpm/node-sass@4.14.1/node_modules/node-sass: Running postinstall script, failed in 1.1s .../node_modules/node-sass postinstall$ node scripts/build.js │ Building: /Users/joshtoth/.nvm/versions/node/v18.16.0/bin/node /Users/joshtoth/dev/my_project_dir/node_modules/. │ gyp info it worked if it ends with ok │ gyp verb cli [ │ gyp verb cli '/Users/joshtoth/.nvm/versions/node/v18.16.0/bin/node', │ gyp verb cli '/Users/joshtoth/dev/my_project_dir/node_modules/.pnpm/node-gyp@3.8.0/node_modules/node-gyp/bin/n │ gyp verb cli 'rebuild', │ gyp verb cli '--verbose', │ gyp verb cli '--libsass_ext=', │ gyp verb cli '--libsass_cflags=', │ gyp verb cli '--libsass_ldflags=', │ gyp verb cli '--libsass_library=' │ gyp verb cli ] │ gyp info using node-gyp@3.8.0 │ gyp info using node@18.16.0 | darwin | arm64 │ gyp verb command rebuild [] │ gyp verb command clean [] │ gyp verb clean removing "build" directory │ gyp verb command configure [] │ gyp verb check python checking for Python executable "python2" in the PATH │ gyp verb `which` succeeded python2 /Users/joshtoth/.pyenv/shims/python2 │ gyp verb check python version `/Users/joshtoth/.pyenv/shims/python2 -c "import sys; print "2.7.18 │ gyp verb check python version .%s.%s" % sys.version_info[:3];"` returned: %j │ gyp verb get node dir no --target version specified, falling back to host node version: 18.16.0 │ gyp verb command install [ '18.16.0' ] │ gyp verb install input version string "18.16.0" │ gyp verb install installing version: 18.16.0 │ gyp verb install --ensure was passed, so won't reinstall if already installed │ gyp verb install version is already installed, need to check "installVersion" │ gyp verb got "installVersion" 9 │ gyp verb needs "installVersion" 9 │ gyp verb install version is good │ gyp verb get node dir target node version installed: 18.16.0 │ gyp verb build dir attempting to create "build" dir: /Users/joshtoth/dev/my_project_dir/node_modules/.pnpm/node- │ gyp verb build dir "build" dir needed to be created? /Users/joshtoth/dev/my_project_dir/node_modules/.pnpm/node- │ gyp verb build/config.gypi creating config file │ gyp verb build/config.gypi writing out config file: /Users/joshtoth/dev/my_project_dir/node_modules/.pnpm/node-s │ (node:62373) [DEP0150] DeprecationWarning: Setting process.config is deprecated. In the future the property will be │ (Use `node --trace-deprecation ...` to show where the warning was created) │ gyp verb config.gypi checking for gypi file: /Users/joshtoth/dev/my_project_dir/node_modules/.pnpm/node-sass@4.1 │ gyp verb common.gypi checking for gypi file: /Users/joshtoth/dev/my_project_dir/node_modules/.pnpm/node-sass@4.1 │ gyp verb gyp gyp format was not specified; forcing "make" │ gyp info spawn /Users/joshtoth/.pyenv/shims/python2 │ gyp info spawn args [ │ gyp info spawn args '/Users/joshtoth/dev/my_project_dir/node_modules/.pnpm/node-gyp@3.8.0/node_modules/node-gy │ gyp info spawn args 'binding.gyp', │ gyp info spawn args '-f', │ gyp info spawn args 'make', │ gyp info spawn args '-I', │ gyp info spawn args '/Users/joshtoth/dev/my_project_dir/node_modules/.pnpm/node-sass@4.14.1/node_modules/node- │ gyp info spawn args '-I', │ gyp info spawn args '/Users/joshtoth/dev/my_project_dir/node_modules/.pnpm/node-gyp@3.8.0/node_modules/node-gy │ gyp info spawn args '-I', │ gyp info spawn args '/Users/joshtoth/.node-gyp/18.16.0/include/node/common.gypi', │ gyp info spawn args '-Dlibrary=shared_library', │ gyp info spawn args '-Dvisibility=default', │ gyp info spawn args '-Dnode_root_dir=/Users/joshtoth/.node-gyp/18.16.0', │ gyp info spawn args '-Dnode_gyp_dir=/Users/joshtoth/dev/my_project_dir/node_modules/.pnpm/node-gyp@3.8.0/node_ │ gyp info spawn args '-Dnode_lib_file=/Users/joshtoth/.node-gyp/18.16.0/<(target_arch)/node.lib', │ gyp info spawn args '-Dmodule_root_dir=/Users/joshtoth/dev/my_project_dir/node_modules/.pnpm/node-sass@4.14.1/ │ gyp info spawn args '-Dnode_engine=v8', │ gyp info spawn args '--depth=.', │ gyp info spawn args '--no-parallel', │ gyp info spawn args '--generator-output', │ gyp info spawn args 'build', │ gyp info spawn args '-Goutput_dir=.' │ gyp info spawn args ] │ Traceback (most recent call last): │ File "/Users/joshtoth/dev/my_project_dir/node_modules/.pnpm/node-gyp@3.8.0/node_modules/node-gyp/gyp/gyp_main. │ sys.exit(gyp.script_main()) │ File "/Users/joshtoth/dev/my_project_dir/node_modules/.pnpm/node-gyp@3.8.0/node_modules/node-gyp/gyp/pylib/gyp │ return main(sys.argv[1:]) │ File "/Users/joshtoth/dev/my_project_dir/node_modules/.pnpm/node-gyp@3.8.0/node_modules/node-gyp/gyp/pylib/gyp │ return gyp_main(args) │ File "/Users/joshtoth/dev/my_project_dir/node_modules/.pnpm/node-gyp@3.8.0/node_modules/node-gyp/gyp/pylib/gyp │ options.duplicate_basename_check) │ File "/Users/joshtoth/dev/my_project_dir/node_modules/.pnpm/node-gyp@3.8.0/node_modules/node-gyp/gyp/pylib/gyp │ params['parallel'], params['root_targets']) │ File "/Users/joshtoth/dev/my_project_dir/node_modules/.pnpm/node-gyp@3.8.0/node_modules/node-gyp/gyp/pylib/gyp │ variables, includes, depth, check, True) │ File "/Users/joshtoth/dev/my_project_dir/node_modules/.pnpm/node-gyp@3.8.0/node_modules/node-gyp/gyp/pylib/gyp │ includes, True, check) │ File "/Users/joshtoth/dev/my_project_dir/node_modules/.pnpm/node-gyp@3.8.0/node_modules/node-gyp/gyp/pylib/gyp │ aux_data, includes, check) │ File "/Users/joshtoth/dev/my_project_dir/node_modules/.pnpm/node-gyp@3.8.0/node_modules/node-gyp/gyp/pylib/gyp │ LoadOneBuildFile(include, data, aux_data, None, False, check), │ File "/Users/joshtoth/dev/my_project_dir/node_modules/.pnpm/node-gyp@3.8.0/node_modules/node-gyp/gyp/pylib/gyp │ None) │ File "/Users/joshtoth/.node-gyp/18.16.0/include/node/common.gypi", line 1 │ 'uv_library%': 'static_library', │ ^ │ SyntaxError: invalid syntax │ gyp ERR! configure error │ gyp ERR! stack Error: `gyp` failed with exit code: 1 │ gyp ERR! stack at ChildProcess.onCpExit (/Users/joshtoth/dev/my_project_dir/node_modules/.pnpm/node-gyp@3.8. │ gyp ERR! stack at ChildProcess.emit (node:events:513:28) │ gyp ERR! stack at ChildProcess._handle.onexit (node:internal/child_process:291:12) │ gyp ERR! System Darwin 22.6.0 │ gyp ERR! command "/Users/joshtoth/.nvm/versions/node/v18.16.0/bin/node" "/Users/joshtoth/dev/my_project_dir/node │ gyp ERR! cwd /Users/joshtoth/dev/my_project_dir/node_modules/.pnpm/node-sass@4.14.1/node_modules/node-sass │ gyp ERR! node -v v18.16.0 │ gyp ERR! node-gyp -v v3.8.0 │ gyp ERR! not ok │ Build failed with error code: 1 └─ Failed in 1.1s at /Users/joshtoth/dev/my_project_dir/node_modules/.pnpm/node-sass@4.14.1/node_modules/node-sass ELIFECYCLE Command failed with exit code 1. /Users/joshtoth/dev/my_project_dir/node_modules/.pnpm/projen@0.77.1_constructs@10.3.0/node_modules/projen/src/task-runtime.ts:204 throw new Error( ^ Error: Task "install" failed when executing "pnpm i --no-frozen-lockfile" (cwd: /Users/joshtoth/dev/my_project_dir) at new RunTask (/Users/joshtoth/dev/my_project_dir/node_modules/.pnpm/projen@0.77.1_constructs@10.3.0/node_modules/projen/src/task-runtime.ts:204:17) at TaskRuntime.runTask (/Users/joshtoth/dev/my_project_dir/node_modules/.pnpm/projen@0.77.1_constructs@10.3.0/node_modules/projen/src/task-runtime.ts:76:5) at NodePackage.installDependencies (/Users/joshtoth/dev/my_project_dir/node_modules/.pnpm/projen@0.77.1_constructs@10.3.0/node_modules/projen/src/javascript/node-package.ts:1502:13) at NodePackage.postSynthesize (/Users/joshtoth/dev/my_project_dir/node_modules/.pnpm/projen@0.77.1_constructs@10.3.0/node_modules/projen/src/javascript/node-package.ts:866:12) at MonorepoTsProject.synth (/Users/joshtoth/dev/my_project_dir/node_modules/.pnpm/projen@0.77.1_constructs@10.3.0/node_modules/projen/src/project.ts:618:14) at MonorepoTsProject.synth (/Users/joshtoth/dev/my_project_dir/node_modules/.pnpm/@aws+pdk@0.22.42_@aws-cdk+aws-cognito-identitypool-alpha@2.110.1-alpha.0_@pnpm+logger@5.0.0_@_xbq6lcvsguulglgpaubb2xhoey/node_modules/@aws/pdk/monorepo/projects/typescript/monorepo-ts.ts:545:11) at Object.Reproduction Steps
establish a new pdk project using the ts-monorepo command.
add this into the projenrc
and run
pdk
In between tests of package name changes, ensure the directory
frontend
is deleted before usingpdk
again.Possible Solution
No response
Additional Information/Context
pnpm store pruned, no change. ~/.pdk rm -rf'd , no change
PDK version used
0.22.10
What languages are you seeing this issue on?
Typescript
Environment details (OS name and version, etc.)
MacOS 13.5.1, node: 20.5.0 and 18.16.0