Tag Archives: Unexpected token

R: Data frame index error “unexpected token”

Objective: to practice PCA analysis with prcomp function
data set: R comes with iris data set
error reporting content: when removing the “species” column in Iris data set with data frame index, errors are always reported, as follows:

> iris_data <- [,-5] 
Error: Unexpected'[' in "iris_data <- ["

Oh, it’s really a very low-level error. The reason for the error is that the data set is not indicated. After modification, the code is as follows:

iris_data <- iris[,-5]

the second similar problem:
original code:

fviz_pca_ind(iris.pca,
             geom.ind = ("point", "text"), # show points only (nbut not "text")
             col.ind = iris$Species, # color by groups
             palette = c("#00AFBB", "#E7B800", "#FC4E07"),
             addEllipses = TRUE, # Concentration ellipses
             legend.title = "Groups"
             )

report errors:

Error: Unexpected',' in:
"fviz_pca_ind(iris.pca,
             geom.ind = ("point","

Modified code: added “C” in front

fviz_pca_ind(iris.pca,
             geom.ind = c("point", "text"), # show points only (nbut not "text")
             col.ind = iris$Species, # color by groups
             palette = c("#00AFBB", "#E7B800", "#FC4E07"),
             addEllipses = TRUE, # Concentration ellipses
             legend.title = "Groups"
             )

Vue の NPM run serve error: parsing error: unexpected token<

error: Parsing error: Unexpected token <  

Although this error occurred, it did not affect the operation of the project.
Solution:
Run installation dependency

npm install --save-dev babel-plugin-transform-object-rest-spread

Then create the.babelrc.js file in the project directory and add the following code

babel: {
    presets: [
        'es2015'
    ]
    Plugins: [
        'transform-object-rest-spread'
    ]
}

Rerun, error is gone.

Follow-up update solutions:
If the above methods will also appear error Parsing error: Unexpected Token, add the following code
Start with the installation dependencies

npm install babel-eslint --save

Then add code parsing to.eslintrc.js

"parser": "babel-eslint" 

Restart it.

Module build failed: SyntaxError: Unexpected token

vue router loading on demand times error

{
	path: '/product',
	component: () => import('./pages/product'),
},

error: Module build failed: SyntaxError: Unexpected token

solution:

1. In the beginning, I was in a hurry to write something, but instead of studying it carefully, I changed it to another way:
{
	path: '/product',
	component:resolve => require(['./pages/product'], resolve),
},

found no error and ran successfully. Later baidu checked that the original Babel needs to be added with syntax-dynamic-import plug-in, so that the Babel can correctly parse the syntax.

2. Download the plug-in
npm install babel-plugin-syntax-dynamic-import --save-dev
3. Then modify the loader configuration

in webpack

{
	test: /\.js$/,
	loader:'babel-loader',
	options:{
		plugins:['syntax-dynamic-import']
	},
},

so far, problem solved

my personal blog, drop by sometime