Recently developed an old project, I found that the project that was good before is now running an error, Various switching of npm sources and node versions does not work, Google did not find relevant information, The error is as follows:
error in ./node_modules/@lit/reactive-element/decorators/state.js Module parse failed: Unexpected token (6:27) You may need an appropriate loader to handle this file type. | * Copyright 2017 Google LLC | * SPDX-License-Identifier: BSD-3-Clause | */function t(t){return r({...t,state:!0})}export{t as state}; | //# sourceMappingURL=state.js.map
It says that the current file cannot be processed.
error in ./node_modules/@lit/reactive-element/decorators/state.js
Module parse failed: Unexpected token (6:27)
You may need an appropriate loader to handle this file type.
| * Copyright 2017 Google LLC
| * SPDX-License-Identifier: BSD-3-Clause
| */function t(t){return r({...t,state:!0})}export{t as state};
| //# sourceMappingURL=state.js.map
|
It is found that the file under the @lit module reports an error, click on the details and find that the source file here, is not es5 syntax.
Look at the version number in package.json, the ^ is used, which means that this module can be automatically minor version upgrade. Guess it should be that the module is automatically upgraded, causing some incompatibility so an error is reported,
Finally, I found that the project is configured with, babel parsing, this plugin outputs es6 code, needs to be compiled with bable.
{
test: /\.js$/,
loader: 'babel-loader',
include: [
[resolve('src'), resolve('/node_modules/_@lit')]
],
}
See the error message is ./node_modules/@lit/reactive-element , the original path of the new version was changed to @lit,The old version is _@lit So there is no bable parsing, resulting in an error. After the following modification, a new parsing path has been added, The problem has been solved.
{
test: /\.js$/,
loader: 'babel-loader',
include: [
[resolve('src'), resolve('/node_modules/_@lit'), resolve('/node_modules/@lit') ]
],
}
Read More:
- [Solved] ERROR in ./node_modules/element-ui/lib/theme-chalk/fonts/element-icons.ttf
- ArcGIS API for JavaScript version 4. X updated and the project startup error: Module parse failed: Unexpected token(… …
- [Solved] This dependency was not found: * core-js/modules/es.error.cause.js in ./node_modules/_@babel_runtim
- [Solved] Error: ENOENT: no such file or directory, scandir ‘..\node_modules\node-sass\vendor‘
- [Solved] error C:\Users\HP\Desktop\VueProject\vue_cli\node_modules\node-sass: Command failed.Exit code: 1
- node.js yarn Error: SyntaxError: Unexpected string [How to Solve]
- [Solved] Uniapp project use vant icon Error: (module build failed from./node_modules/postcss loader/SRC/index)
- Vue Package Image Error: Syntax Error: Error: ‘**\node_modules\pngquant-bin\vendor\pngquant.exe‘
- How to Solve JS error: Unexpected end of JSON input,Unexpected token u in JSON at position 0
- [Solved] Temporary error: Error: spawn E:\vue3-vite\my-app\node_modules\esbuild\esbuild.exe ENOENT
- [Solved] Vuex state Error: [vuex] do not mutate vuex store state outside mutation handlers.
- Vue Import element-plus Error: Failed to resolve import “element-pluslibtheme-chalkindex.css“ from “src
- [Solved] JSON.parse() Error: Unexpected end of JSON input
- [Solved] Vue Error: Module build failed Error Node Sass version 6.0.1 is incompatible with ^4.0.0.
- [vite] Failed to parse source for import analysis because the content contains invalid JS syntax.
- Node.js Error: Error: Cannot find module ‘express‘ [How to Solve]
- Error in created hook: “SyntaxError: Unexpected token u in JSON at position 0
- Module not found: Error: Can‘t resolve ‘core-js/modules/es.promise.js‘ in
- Json.parse: All Error & How to Solve Them
- [Solved] Node Create Express Project Error: Failed to lookup view “error“ in views directory