I am having an issue with babel building angular app for production - babeljs

Current Behavior
I am building my angular project on circleci and it just keeps failing with the following message:
An unhandled exception occurred: Cannot find module
'#babel/compat-data/corejs3-shipped-proposals'
Require stack:
/home/circleci/eleven-app/frontend/node_modules/#angular-devkit/build-angular/node_modules/#babel/preset-env/lib/polyfills/corejs3/usage-plugin.js
/home/circleci/eleven-app/frontend/node_modules/#angular-devkit/build-angular/node_modules/#babel/preset-env/lib/index.js
/home/circleci/eleven-app/frontend/node_modules/#angular-devkit/build-angular/node_modules/#babel/core/lib/config/files/plugins.js
/home/circleci/eleven-app/frontend/node_modules/#angular-devkit/build-angular/node_modules/#babel/core/lib/config/files/index.js
/home/circleci/eleven-app/frontend/node_modules/#angular-devkit/build-angular/node_modules/#babel/core/lib/index.js
/home/circleci/eleven-app/frontend/node_modules/#angular-devkit/build-angular/src/utils/process-bundle.js
/home/circleci/eleven-app/frontend/node_modules/jest-worker/build/workers/processChild.js
I am using
{
"#babel/plugin-proposal-numeric-separator": "^7.8.3",
"core-js": "3.2.1",
"tslib": "^1.11.1",
"#babel/compat-data": "~7.8.0",
"#babel/runtime-corejs3": "^7.9.2",
"ts-node": "7.0.0",
"tslint": "5.11.0",
"typescript": "3.5.3",
}
resolutions: {
"#babel/preset-env": "^7.8.7"
}
here is npx nls why #babel/preset-env output:
eleven-app-frontend > #angular-devkit/build-angular > #babel/preset-env#7.8.7
eleven-app-frontend > #nrwl/angular > #nrwl/cypress > #cypress/webpack-preprocessor > #babel/preset-env#7.9.5
eleven-app-frontend > #nrwl/cypress > #cypress/webpack-preprocessor > #babel/preset-env#7.9.5
Thank you for reading.

Had the same issue today, so I'm assuming there's something weird with the latest version.
My package.json had the following:
"#babel/compat-data": "~7.9.0"
I removed the ~ to force 7.9.0 instead of allowing newer ones and it did the trick for me.
There's probably a newer version that works but since you opened an issue for them (https://github.com/babel/babel/issues/11427) I'll just wait for more details.

I've the same issue when using TravisCI & Vue with Jest and Babel. My test suit has been failing. Adding "#babel/compat-data": "7.9.0" to devDependencies in my package.json file solved my problems.

These 3 options we came up with so far:
Adapt dependency of babel/preset-env to v7.9.0: "#babel/preset-env": "=7.9.0"
In case you use a NodeJS Docker Image, fix the version to something below 13.13, i.e.: node:13.12.0-alpine
Adding or upgrading "#babel/compat-data": "7.9.0" to devDependencies
The solutions are temporarily and should be removed as soon as there is an actual fix of the node images or the babel/preset-env library.
Linked Github issues:
babel - https://github.com/babel/babel/issues/11427
nodejs - https://github.com/nodejs/node/issues/32852#issuecomment-613652057

I had the same issue today in Github Actions build for a Vue FE project. It builds fine locally. I'm going to try the solution above and I'll report back...
Update: After looking through the package-lock file, my solution was to explicitly add "#babel/compat-data" to the prod dependencies. Previously it was only a dependency for some dev dependencies. So my package.json now looks like:
"dependencies": {
"#babel/compat-data": "^7.8.6",
...

Same issue.
Solved it by following above advices + removing node_modules (see this github thread):
Added explicitly #babel/compat-data": "7.9.0" to devDependencies
Upgraded node (13.3 to 14.0 in my case)
Had to remove my node_modules folder and re run yarn (or npm)

If you're using yarn, try to remove the yarn.lock file in your project. And then reinstall by run yarn install; you'll get a new yarn.lock file, which is fine.
It worked for me in my Next.js project.

Related

RN 0.56 throws error 'React/RCTBridgeModule.h' file not found

Long story short, I got very very old RN IOS project (dependency list can show you how old) which works on only one company macbook. Thing is that this macbook has already some problems and I wished to install everything on my current mac, Unfortunately it throws many errors and I don't really know what to do with them. Project works on previous mac with XCode 12.5, I installed same version here just to make sure, also node v8.17.0 is used in previous mac so I used nvm to get same version.
Package.json
dependencies": {
"react": "^16.4.1",
"react-dom": "^16.4.2",
"react-native": "0.56",
"react-native-axios": "^0.17.1",
"react-native-barcode-builder": "^1.0.5",
"react-native-ble-manager": "^6.5.1",
"react-native-bluetooth-status": "^1.3.0",
"react-native-canvas": "^0.1.23",
"react-native-color-matrix-image-filters": "^5.2.0",
"react-native-cookies": "^3.3.0",
"react-native-linear-gradient": "^2.4.2",
"react-native-pulse": "^1.0.6",
"react-native-restart": "0.0.7",
"react-native-safari-view": "^2.1.0",
"react-native-side-menu": "^1.1.3",
"react-native-splash-screen": "^3.1.1",
"react-native-vector-icons": "^5.0.0"
},
So i go clone, np install and then npx react-native start, try to launch it in XCode and then build fails with:
'React/RCTBridgeModule.h' file not found in several libraries. As far as I can see in "Build Phases" > "Link binary with Libraries" they are there
EDIT
Ok I tried to take approach signed as a answer from link in comments, it went a bit further but now it crash on:
Showing Recent Messages
Build input file cannot be found: '../node_modules/react-native/third-party/glog-0.3.4/src/vlog_is_on.cc'
Showing Recent Messages
Build input file cannot be found: '../node_modules/react-native/third-party/glog-0.3.4/src/utilities.cc'
Showing Recent Messages
Build input file cannot be found: '../node_modules/react-native/third-party/glog-0.3.4/src/logging.cc'
Showing Recent Messages
Build input file cannot be found: '../node_modules/react-native/third-party/glog-0.3.4/src/symbolize.cc'
I managed to make it works! Thanks for comment it really helped me to move first step which was the hardest, so basically what I had to do, maybe it will be useful for someone who tries to launch some old project:
In XCode goes to Build Phases, manually unlink all external libraries and then re-add them again
Move React.xcodeproj from libraries to root folder and then in Build Phases => dependency > add React
Goes with the link from comment and disable "Parallelize Build"
Proceed with this link in case of glog error => https://github.com/facebook/react-native/issues/14382 (here I a bit messed up with several answers but moreless I did this yarn cache clean rm -rf node_modules yarn install and then this => https://github.com/facebook/react-native/issues/14382#issuecomment-405472763 and https://github.com/facebook/react-native/issues/14382#issuecomment-422755411)
Then in case of RCTBridge error I go with this answer => https://github.com/facebook/react-native/issues/31412#issuecomment-872032401
And in the end when app was succesfuly build but crash on launch I went with Solution number 2 from this link => https://blog.cpming.top/p/rn-error-unknown-argument-type-attribute-in-method

warning Lockfile has incorrect entry for "prismjs#1.24.0". Ignoring it

I have inherited an issue with prismjs whereby I have to remove/reinstall it every time I add/upgrade another package.
I have a gocd pipeline validation that fails every time I try to use dependabot to address security vulnerabilities on my repo.
Goes something like this....
dependabot generates pull request
validation fails with error "warning Lockfile has incorrect entry for "prismjs#1.24.0". Ignoring it"
Pull down master branch > upgrade package manually > remove/install prismjs#1.24.0
Generate new PR > validation succeeds and everything works fine.
Merge with master
rinse and repeat.
What I am seeing is that I have 2 entries in my yarn.lock for prismjs and removing it only removes the 1.24.0 entry AND, if I leave 1.24.0 removed the validation still fails because it cant find prismjs 1.24.0.
prismjs#1.24.0:
version "1.24.0"
resolved "https://registry.yarnpkg.com/prismjs/-/prismjs-1.24.0.tgz#0409c30068a6c52c89ef7f1089b3ca4de56be2ac"
integrity sha512-SqV5GRsNqnzCL8k5dfAjCNhUrF3pR0A9lTDSCUZeh/LIshheXJEaP0hwLz2t4XHivd2J/v2HR+gRnigzeKe3cQ==
prismjs#^1.23.0, prismjs#^1.8.4, prismjs#~1.17.0:
version "1.26.0"
resolved "https://registry.yarnpkg.com/prismjs/-/prismjs-1.26.0.tgz#16881b594828bb6b45296083a8cbab46b0accd47"
integrity sha512-HUoH9C5Z3jKkl3UunCyiD5jwk0+Hz0fIgQ2nbwU2Oo/ceuTAQAg+pPVnfdt2TJWRVLcxKh9iuoYDUSc8clb5UQ==
package.json:
"dependencies": {
"comma-separated-tokens": "^1.0.0",
"elliptic": "^6.0.0",
"handlebars": "^4.1.2",
"http-proxy": "^1.17.0",
"https-proxy-agent": "^2.2.1",
"immer": "9.0.6",
"ini": "^1.3.5",
"lodash": "^4.5.1",
"markdown-to-jsx": "^6.9.1",
"merge-deep": "^3.0.2",
"nested-object-assign": "1.0.4",
"parse-headers": "^2.0.0",
"prismjs": "1.24.0",
"space-separated-tokens": "^1.0.0",
"ssri": "^6.0.1",
"tar": "4.4.19",
"tree-kill": "^1.1.0",
"ua-parser-js": "^0.7.9",
"url-parse": "^1.4.3",
"websocket-extensions": ">=0.1.1",
"y18n": "^4.0.0",
"yargs-parser": "^13.1.1"
},
"resolutions": {
"prismjs": "^1.23.0",
"property-expr": "^2.0.3"
I'm relatively new to how this versioning works and like I say I inherited this issue so I don't really have a history besides what I can see in github.
Any help would be greatly appreciated.
By Running yarn why prismjs that will explain which packages other than your project depend on prismjs.
I'm not sure if you've other packages that depend on prismjs to explain these other entries. It seems that some of the dependencies are hoisted to me. If you've a monorepo setup or work with nested packages, that could explain it.
Maybe helpful info as well, according to Yarn docs
You will receive a warning if your resolution version or range is not compatible with the original version range.
Nested packages may not work properly.

How to solve jsdoc PluginConflictError in Grafana panel plugin?

I've made a Grafana panel plugin that has worked fine in the past, but now I'm getting this error when I run yarn dev (i.e. grafana-toolkit plugin:dev) to build the plugin:
Plugin "jsdoc" was conflicted between "--config » #grafana/eslint-config" and "../../../.eslintrc » #grafana/eslint-config"
I'm using the following Grafana dependencies:
"#grafana/data": "^7.4.3",
"#grafana/runtime": "^7.4.3",
"#grafana/toolkit": "^7.4.3",
"#grafana/ui": "^7.4.3",
I've tried updating the dependencies to Grafana 8, clearing modules cache and re-installing modules but can't get rid of the error. I'm not sure what to do, since it looks like a conflict within the #grafana dependencies. Any ideas?
I fixed it by moving the plugin out of my cloned grafana repo /plugins folder and editing the path for "plugins" in the default.ini file in grafana to point to the folder outside grafana. I've always just run the plugin inside grafana, but that no longer works for me. Maybe I missed that somewhere in the documentation.
I had the same problem. It appears to be a conflict with eslint config in a parent directory. I fixed it by adding a .eslintrc in the plugin directory with the following contents. The root: true flag indicates that this is the top level config.
{
"extends": ["#grafana/eslint-config"],
"root": true
}

parcel bundler - Unknown plugin "add-module-exports"

I'm trying to use 'react-responsive' but I am getting the error message - Unknown plugin "add-module-exports
It looks like this relates to the fact that node_modules needs to be excluded but due to a bug in babel v6 (fixed in v7) adding "ignore": "node_modules" to the .babelrc file doesn't work.
https://github.com/contra/react-responsive/issues/131
It seems like parcel-bundler uses babel v6 so my question is , how can I ignore node_modules and get parcel to bundle without throwing an error?
I was facing a similar issue recently with parcel, installing babel-plugin-add-module-exports seemed to fix the issue

Material-UI v1.0.0.-beta Issue with React-Transition-Group

While testing material-ui v1.0.0-beta, I encountered with the following error when building using webpack 3.8.0. I came across with few other questions like this, too, but am hoping if someone could confirm this is a legitimate issue and is still seen by people? I even added "react-transition-group": "^2.2.1" to package.json and so far no luck. Thanks in advance for your help.
ERROR in ../node_modules/material-ui-next/ButtonBase/Ripple.js
Module not found: Error: Can't resolve 'react-transition-group/Transition' in './node_modules/material-ui-next/ButtonBase'
I have "react-router": "^3.2.0", in my package.json in case this may help folks understand what might be the root cause.
[UPDATE] While investigating, I removed node_modules and issued npm cache clean as well as ensure the global cache is cleared by issuing npm ls -gp --depth=0 | awk -F/ '/node_modules/ && !/\/npm$/ {print $NF}' | xargs npm -g rm. This didn't fix the issue.
Follow the steps explained in this ticket for solution: material-ui-next/9356
Summary of Solution
The issue relates to how webpack searches for dependencies at build time and establishes the dependency graph of all peer dependencies for each and every module. When digging further, I noted that material-ui#0.19.4 has react-transition-group#1.2.1 as its peer dependency while material-ui-next#1.0.0 beta has react-transition-group#2.2.1 as its peer dependency. Furthermore, I suspect because I have both material-ui releases on my project, when importing a component from material-ui-next, the expected path for react-transition-group#2.2.1 from material-ui-next's perspective is project/node_modules but apparently due to having two versions of material-ui, the later installs react-transition-group#2.2.1 under material-ui-next.
In webpack path configurations, add the following:
module.exports = {
app: path.resolve(CURRENT_WORKING_DIR, "app"),
assets: path.resolve(CURRENT_WORKING_DIR, "public", "assets"),
compiled: path.resolve(CURRENT_WORKING_DIR, "compiled"),
public: "/assets/",
modules: path.resolve(CURRENT_WORKING_DIR, "node_modules"),
extraModules: path.resolve(CURRENT_WORKING_DIR,
"node_modules/material-ui-next/node_modules"),
};
And finally add the extra path to webpack's resolve attribute:
module.exports = {
modules: [PATHS.app, PATHS.modules, PATHS.extraModules],
extensions: [".js", ".jsx", ".css"],
};
to fix above issue:
please install react-transition-group
npm i react-transition-group#next --save