babel: [Bug]: Something tricky with the latest babel/traverse
💻
- Would you like to work on a fix?
How are you using Babel?
Input code
You gave us a visitor for the node type ClassAccessorProperty but it’s not a valid type
Configuration file name
No response
Configuration
No response
Current and expected behavior
From today I’m getting the below error, not able buildmy nextjs project,
You gave us a visitor for the node type ClassAccessorProperty but it's not a valid type
> Build error occurred
Error: > Build failed because of webpack errors
at build (/Users/saikiran/Downloads/projects/olb-navigation/Navigation/frontend/node_modules/next/dist/build/index.js:15:918)
Below is my package.json file,
"name": "",
"version": "0.0.1",
"private": true,
"description": "",
"keywords": [
"navigation"
],
"homepage": "",
"bugs": {
"url": "",
"email": ""
},
"author": {
"name": "",
"email": ""
},
"contributors": [
"",
""
],
"files": [
"lib"
],
"main": "lib/index.js",
"repository": {
"type": "git",
"url": ""
},
"scripts": {
"build": "make -s .build",
"clean": "make -s clean",
"coverage": "make -s coverage",
"format": "make -s format",
"lint": "echo",
"make": "make",
"preinstall": "make -s preinstall",
"prepare": "make -s prepare",
"purge": "make -s purge",
"spellcheck": "make -s spellcheck",
"start": "make -s start",
"test": "echo",
"test-cov": "echo"
},
"dependencies": {
"@emotion/styled": "^11.0.0",
"@rebass/forms": "^4.0.6",
"@testing-library/react-hooks": "^3.4.2",
"@theme-ui/presets": "^0.3.3",
"@zeit/next-source-maps": "^0.0.3",
"axios": "^0.21.0",
"axios-mock-adapter": "^1.19.0",
"axios-observable": "^1.1.3",
"classnames": "^2.2.6",
"core-js": "^3.6.5",
"global": "^4.4.0",
"lodash": "^4.17.20",
"lodash.merge": "^4.6.2",
"next": "10.0.3",
"next-images": "^1.6.2",
"opinionated-redux": "^0.0.4",
"pkg-dir": "^5.0.0",
"prop-types": "^15.7.2",
"q2-tecton-hooks": "^0.0.5",
"q2-tecton-sdk": "^1.43.0",
"react": "^17.0.2",
"react-dom": "^17.0.1",
"react-redux": "^7.2.1",
"rebass": "^4.0.7",
"redux": "^4.0.5",
"redux-observable": "^1.2.0",
"rxjs": "^6.6.3",
"save": "^2.9.0",
"styled-components": "^5.2.0",
"styled-system": "^5.1.5",
"theme-ui": "^0.8.4",
"ua-parser-js": "^0.7.26"
},
"devDependencies": {
"@babel/cli": "^7.12.1",
"@babel/core": "^7.12.3",
"@babel/node": "^7.12.6",
"@babel/plugin-proposal-class-properties": "^7.12.1",
"@babel/plugin-proposal-decorators": "^7.12.1",
"@babel/plugin-proposal-optional-chaining": "^7.12.1",
"@babel/plugin-transform-react-jsx": "^7.12.5",
"@babel/plugin-transform-runtime": "^7.12.1",
"@babel/plugin-transform-typescript": "^7.19.3",
"@babel/preset-env": "^7.12.7",
"@babel/preset-react": "^7.12.1",
"@babel/preset-typescript": "^7.12.1",
"@babel/runtime": "^7.12.1",
"@emotion/babel-plugin-jsx-pragmatic": "^0.1.5",
"@emotion/react": "^11.0.0",
"@ringcentral/gitlab-sonarqube-echo-coverage": "^0.1.1",
"@storybook/addon-a11y": "^6.0.27",
"@storybook/addon-actions": "^6.0.27",
"@storybook/addon-console": "^1.2.2",
"@storybook/addon-jest": "^6.0.27",
"@storybook/addon-knobs": "^6.0.27",
"@storybook/addon-links": "^6.0.27",
"@storybook/addon-storysource": "^6.0.28",
"@storybook/addon-viewport": "^6.0.27",
"@storybook/addons": "7.1.1",
"@storybook/source-loader": "^6.0.27",
"@testing-library/react": "^11.1.0",
"@types/chai": "^4.2.14",
"@types/chai-as-promised": "^7.1.3",
"@types/classnames": "^2.2.10",
"@types/enzyme": "^3.10.7",
"@types/enzyme-adapter-react-16": "^1.0.6",
"@types/jest": "^26.0.15",
"@types/lodash.merge": "^4.6.6",
"@types/mocha": "^8.0.3",
"@types/react": "^17.0.0",
"@types/react-redux": "^7.1.9",
"@types/react-test-renderer": "^17.0.0",
"@types/rebass": "^4.0.7",
"@types/theme-ui": "^0.3.7",
"@typescript-eslint/eslint-plugin": "^4.5.0",
"@typescript-eslint/parser": "^4.5.0",
"babel-plugin-module-resolver": "^4.0.0",
"cloc": "^2.7.0",
"cspell": "^4.1.3",
"enzyme": "^3.11.0",
"enzyme-adapter-react-16": "^1.15.5",
"eslint": "^7.12.0",
"eslint-config-airbnb-typescript": "^12.0.0",
"eslint-config-prettier": "^6.14.0",
"eslint-plugin-import": "^2.22.1",
"eslint-plugin-jsx-a11y": "^6.4.1",
"eslint-plugin-react": "^7.21.5",
"gnumake": "^0.3.5",
"identity-obj-proxy": "^3.0.0",
"jest": "^26.6.3",
"jest-sonar-reporter": "^2.0.0",
"lockfile-lint": "^4.3.7",
"majestic": "^1.8.0",
"prettier": "^2.1.2",
"react-docgen-typescript-loader": "^3.7.2",
"react-test-renderer": "^17.0.1",
"rxjs-marbles": "^6.0.1",
"sass": "^1.27.0",
"storybook-addon-designs": "^5.4.2",
"storybook-addon-theme-ui": "^0.1.5",
"ts-jest": "^26.4.2",
"typescript": "^4.0.3"
},
"engines": {
"node": ">=6.0.0"
},
"eslintIgnore": [
"lib"
],
"jest": {
"testRegex": "((/(tests|__tests__)((/|/[^_.\n][^/\n]*(/[^_.\n][^/\n]+)*/)[^_.\n][^/\n]*))|((/|/.*/)(([^_.\n][^/\n]*.(spec|test))|(spec|test)))).[jt]sx?$",
"testEnvironment": "node",
"verbose": true,
"testPathIgnorePatterns": [
"<rootDir>/dist/"
],
"setupFilesAfterEnv": [
"<rootDir>/tests/_setup.ts"
],
"moduleNameMapper": {
"\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$": "<rootDir>/tests/_fileMock.ts",
"\\.(css|less)$": "identity-obj-proxy"
}
},
"jestSonar": {
"reportPath": "node_modules/.tmp/reports",
"reportFile": "test-report.xml",
"indent": 4
},
"prettier": {
"singleQuote": true,
"trailingComma": "none"
},
"resolutions": {
"@babel/plugin-transform-typescript": "7.19.3",
"@babel/core": "7.22.6",
"@babel/traverse": "7.25.1",
"@babel/plugin-proposal-decorators": "7.22.5",
"@babel/plugin-transform-runtime": "7.22.5",
"@babel/preset-env": "7.22.5",
"@yarnpkg/parsers": "2.5.1",
"@types/react": "16.14.48"
}
}```
Recently all the babel packages got updated. Not sure what the issue is.
Any leads can be helpful
### Environment
"@babel/traverse": "7.25.1",
### Possible solution
_No response_
### Additional context
_No response_
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 1
- Comments: 42 (20 by maintainers)
Commits related to this issue
- fix(insights): ensure _same_ token is used when rendered multiple times server side in insights middleware: ensure we read from the _initialResults (as insights starts before index is init'ed in getI... — committed to algolia/instantsearch by Haroenv 2 years ago
- fix(insights): ensure the same token is used when rendered multiple times server side (#6456) * fix(insights): ensure _same_ token is used when rendered multiple times server side in insights middle... — committed to algolia/instantsearch by Haroenv 2 years ago
So, here is there thing, I have been re-building from scratch all the time deleting the node_modules…However, after your comment I decided to take a drastic decision lol
Here you’re how I got the build to complete in case anyone ran into the same issue:
Thanks!
The fix for the original issue has been released in
@babel/traverse@7.25.3(older versions are also fine, just not 7.25.0, 7.25.1 and 7.25.2). We also added a test with Next.js 10 to make sure we are not breaking old Next.js versions.If anybody still has problems even when not using one of those three
@babel/traverseversions, please open a new issue.In case anyone is still having issues, I was able to resolve a similar error by simply deleting my
node_modulesfolder and re-installingI was having problems with
"@babel/traverse": "7.22.6"too, upgrade to7.25.3helped.I have suddenly started getting the
_traverse.visitors.environmentVisitoras well in a React Native (0.72.13) project:TypeError: [BABEL]: _traverse.visitors.environmentVisitor is not a function (While processing: /blah/node_modules/metro-react-native-babel-preset/src/index.js)
My package.json:
Upon downgrading the versions gives me the below error,
Is there any way to change the visitor check from error to warning ?
This can help us from build failing and running project on dev.
I have changes .babelrc file, then I’m able to make build working. Able to run the project on dev also.
@liuxingbaoyu @nicolo-ribaudo @JLHwung
Thanks for the support guys.
Could you try deleting
node_modulesand re-installing? Maybe it’s in some corrupt state for some reason.We are seeing the same issue, looks like it is coming from the changes in this PR https://github.com/babel/babel/pull/16649
@wilsolutions please share the full stack trace
Go ahead, I am preparing a e2e test PR for nextjs 10. They can function as a dupcliate e2e babel old versions test. It is easier for us to reproduce the babel/* duplication since they bundled all old babel gems.
@liuxingbaoyu @JLHwung Here is the repo link, https://github.com/KrishnaKiranAlla/babel-build-repo
You can run
nvm useand run theyarn install,yarn buildafter cloning. Then you can see the visitor error.Let me know any findings.
Hoping for the babel to move this error to warning.
@JLHwung So, I tried putting
in package.json file. Now I’m getting different error as below,
Sorry for not understanding. What kind of inputs you need from me?
This is happening from where these babel packages got updated.
As a workaround, you can remove all
@babel/*entries from the lock files and try install again. Or you can runyarn dedupeornpm dedupe, which depends on the package manager you use.The culprit is that there are multiple
@babel/traversein the node_modules and the old babel/traverse can not provide the new babel/traverse method required by some plugins. If there are only one@babel/traversecopy, it should just work.