yarn monorepo with multiple versioning files, fix yarn version check or reset - next.js

Given the following state of my NextJS monorepo app:
monorepo with multiple private packages managed via yarn workspaces
develop is default branch, testing environment and has multiple commits ahead of main
main branch has fewer commits and only those ready for staging environment
commits to main are pushed via PRs with cherry-picking from develop
develop versioning of those private monorepo packages is all green (the yarn version check command)
version checking is disabled PR-level and branch level on main and due to cherry-picking/reverts/squash/etc. the yarn version check fails on the main branch with the following error:
yarn version check
➤ YN0001: UsageError: Your current branch contains multiple versioning files; this isn't supported:
- /Users/tbutcaru/Projects/my-nextjs-app/.yarn/versions/00648a82.yml
- /Users/tbutcaru/Projects/my-nextjs-app/.yarn/versions/009a6542.yml
- /Users/tbutcaru/Projects/my-nextjs-app/.yarn/versions/018f7b67.yml
- /Users/tbutcaru/Projects/my-nextjs-app/.yarn/versions/0197a805.yml
at h (/Users/tbutcaru/Projects/my-nextjs-app/.yarn/plugins/#yarnpkg/plugin-version.cjs:5:3539)
at processTicksAndRejections (internal/process/task_queues.js:93:5)
....
the mentioned .yarn/versions/... files do not exist in my main branch.
Same issue here and here - closed without solution. I've already tried what others have said through comments in the mentioned links.
I've tried:
yarn version apply --all
yarn version check --interactive
upgrade to latest yarn 3.4.0 (using 2.4.2 right now)
deleted all .yarn/versions file dir + yarn.lock and reinstall all packages
manually bump all private packages versions
copy the .yarn/versions file dir from develop to main
added changesetIgnorePatterns: - '.yarn/**/*' in the .yarnrc.yml file and I no longer get the error above but the following YN0000: #my-nextjs-app/shared-components#workspace:packages/shared-components has been modified but doesn't have a release strategy attached and I've run the yarn version check --interactive, so the package has a release strategy attached, but still the yarn version check fails.
... none of the above worked.
How can I fix the "multiple versioning files" issue?
Or, at least, how do I completely reset/reinit the yarn workspace packages versions on the main branch?
Thank you!

Related

I want to open this already created next.js file locally using yarn

I try so many time but it's not working,
I try yarn install to install the yarn first, but it's not installing.
then I try yarn add and then yarn install, but still it's not working. I try next dev. cause I was thinking maybe that's how a next.js file open. but it's still not working.
give me a solution please
and one things, I was trying to create an next.js file but it's not opening. I try this code
yarn create next-app myapp
but it's not working, it's says this error
Usage Error: The nearest package directory (C:\Users\Intel Pc\Downloads\New folder\myapp) doesn't seem to be part of the project declared in C:\Users\Intel P
part of the project declared in C:\Users\Intel Pc.
- If C:\Users\Intel Pc isn't intended to be a project, remove any yarn.lock and/or package.json file there.
- If C:\Users\Intel Pc is intended to be a project, it might be that you forgot to list Downloads/New folder/myapp in its workspace configuration.myapp in its workspace configuration. ly separate project (not even a workspace), crea
- Finally, if C:\Users\Intel Pc is fine and you intend Downloads/New folder/myapp to be treated as a completely separate project (not even a workspace), create an empty yarn.lock file in it.
ev] [-i,--interactive] [--cached] [--mode #0] ..
$ yarn add [--json] [-E,--exact] [-T,--tilde] [-C,--caret] [-D,--dev] [-P,--peer] [-O,--optional] [--prefer-dev] [-i,--interactive] [--cached] [--mode #0] ...
Aborting installation.
yarn add --exact --cwd C:\Users\Intel Pc\Downloads\New folder\myapp react react-dom next has failed.
this image for my existing next.js app which I trying to open locally using yarn but it's not working

Nextjs build in standalone mode hangs with Turborepo (> v1.2.6) and not exit from Gitlab CI pipeline task

I have project with a monorepo on pnpm workspaces and turborepo to manage monorepo scripts.
All the single projects works as expected, they are nextjs projects.
When i upgraded turborepo from the 1.2.6 to the 1.4.0 version and when i run the build script on a gitlab ci, the build task succeeded, but the pipeline keep stuck.
I run the script in this way on the pipeline
.gitlab-ci.yml
.build-dashboard:
image: gitlab.****.it:4567/.../node-pnpm
stage: build
script:
- pnpm build:dashboard
package.json
....
scripts: {
"build:dashboard": "turbo run build --filter=...#project/dashboard && exit 0"
}
...
i try to force the exit using exit 0, but without success (with turobrepo > 1.2.6).
Any suggestions on that ?
Thanks
UPDATE
After many attempt i get an additional log messagge
Attempting to remove file /builds/.../....-user-interface/node_modules/.cache/turbo/a9f0a39c2d3de111/apps/main/.next/standalone/node_modules/.pnpm/supports-color#7.2.0/node_modules/has-flag; a subdirectory is required
As discussed here the problem whas related to turborepo with next build in standalone mode.
Install "turbo": "1.4.4-canary.0" solve the issue.

How to tell Visual Studio Code compiled from source where to find sqlite module?

I am building the Visual Studio Code from the source checked out from the git repository:
git clone https://github.com/microsoft/vscode
I am building using:
export NODE_OPTIONS=--max_old_space_size=2048
./scripts/npm.sh install --arch=armhf
./scripts/code.sh
I am using node 10.16.3 on a Raspberry PI 4, using Raspbian buster
There were no errors during build.
The installation downloads a precompiled version of electron on the first run.
However each time I try and run code, it starts but with an error:
[storage state.vscdb] open(): Unable to open DB due to Error: Cannot find module '../build/Release/sqlite
If I look in node_modules/vscode-sqlite3/build/Release/
I can see:
sqlite3.a
sqlite.a
It is unclear to me why electron/vscode cannot find this library. I would be greatful for any pointers on how to tell the runtime where to look for the modules.
On inspecting the build scripts and after many painful experiments, I've found and solved the 2 problems leading to this error.
The fact that .a static libraries are left behind hinted that some settings in the binding.gyp, config.gpy and/or makefiles are wrong, as Native Node Modules are normally dynamic libraries with an .node extension. One conditional line in the binding.gyp file under vscode-sqlite3 seems to the the culprit:
...
["target_arch=='arm'", {"type": "static_library"}]
...
Disable that line (by removing it or changing 'arm' to something else) and then run:
node-gyp configure
to regenerate the config.gpy file(s) under the build directory. Then build the module with:
node-gyp build
A sqlite.node will be generated in build/Release.
Unfortunately, the latest electron ABI version rarely matches that of the Node.js version. In my configuration, the electron ABI version is 72 (v6.0.12) but the latest stable Node version is for ABI 64. Therefore we have to do an electron-rebuild to update the sqlite.node to match the electron version.
To do this, you would have to first install electron-rebuild (yarn add electron-rebuild) then run electron-rebuild by giving supplying explicitly the version number of the electron binary that vscode downloaded:
electron-rebuild -v 6.0.12 -m /home/dev/vscode -o vscode-sqlite3
Of course you would have to state the version number of your particular version of electron you are building for.
(Please look up electron-rebuild --help for the meaning of the options. It takes a while to rebuild the binary module...)
The resulting sqlite.node can then be moved into the build/Release/. directory under the vscode project directory. Voila, we have a working latest version VS-Code for Raspbian!

How to remove npm files from meteor build

After upgrading Meteor to 1.3.x version NPM really came to play. But as always there is back side of the coin: build size.
On meteor 1.2.x build size is ~50MB, ~7k files
On meteor 1.3.x build size is ~190MB, ~27k files.
Twenty seven thousand files. That's quite a number. Not to mention path size exceeding 256 (a trouble for windows users).
I've dig into what meteor included into the build and it seems that all the npm_modules is here with all the stuff that is need to build some modules and their dependencies.
The question is: how to build meteor app without unnessesary npm files, leaving only the ones that are actually used by app at runtime?
Update:
On meteor 1.4.1_3 if you create a simple project meteor create dummy-project and go through all the common stuff like npm meteor install and meteor npm prune --production and them make a bundle out of it with meteor build c:\dummy --directory you will get a folder with the same 7k files and almost 2k folders (by the way it will not run node main.js out of the box as you might expect). If you tinker through folders you can find babel compiler inside that takes ~3.5k files.
Why do I need babel compiler inside compiled app?
To gain an introspective of your packages,
npm list --depth 0
to see the current packages in your project with only one level.
Inspect that list, and decide if you don't need a package and uninstall it.
You can also use other flags such as
npm list --depth 1 #the number represents the max depth
npm list --long true #for more information about the packages
npm list --global true #to check your global packages.
npm help-search <searchTerm>
Hope that helps you gain more insight in your packages. help-search Link
You may see that multiple packages depends on the same packages, and then it's up to you to decided what your application needs to run successfully.
Edit 1
You can exclude the packages inside your devDependencies, so that when you're publishing/deploying your code you have a cleaner package.
You do this by using npm prune --production - that removes all your devDependencies, and will require your users to do a npm install for your package to work. For info here

Meteor 1.3 node build: doesn't work anymore with React

With 1.2.*, I used to build my staging/production bundles with meteor build, then moving into ./bundle/programs/server and npm install there.
I do the same thing with 1.3 version but now I have error message on trying to run bundle main file with node:
WARNING: npm peer requirements not installed:
- react#0.14.x not installed.
- react-addons-pure-render-mixin#0.14.x not installed.
Read more about installing npm peer dependencies:
http://guide.meteor.com/using-packages.html#peer-npm-dependencies
/var/www/builds/1459320997/bundle/programs/server/node_modules/fibers/future.js:267
throw(ex);
^
Error: Can't find npm module 'react'. Did you forget to call 'Npm.depends' in package.js within the 'modules-runtime' package?
I use react-meteor-data meteor package.
However, I already have "react": "^0.14.8", and "react-addons-linked-state-mixin": "^0.14.8", in my package.json and of course installed it with npm install ... --save and it is working fine on development environment when I use meteor command.
Any additional actions needed to run it? Did they change how meteor package should be build for production and didn't changed their docs? (because I don't see any changes in docs concerning meteor build so far.
Update: I tried to manually npm install these packages into ./bundle/program/server. Now they consequentially requires packages already listed in my package.json. I suppose Meteor just ignore this file on bundle. Will try to add a bug in their tracker.
I used Meteor 1.2 to build new 1.3 code so it is the issue. It happened because currently I build on the server that had another Meteor version.
I used answer from another Stackoverflow user (Ian) Updating all Meteor packages to latest versions
Easiest way is to delete the contents of .meteor/versions and then save

Resources