Category Archives: Javasript

[Solved] Vue pdfjs-dist Error: Module parse failed: Unexpected token (2267:39)

Use pdfjs-dist Error:

Module parse failed: Unexpected token (2267:39)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
|
| async getXfa() {
> return this._transport._htmlForXfa?.children[this._pageIndex] || null;
| }

Solution:

Change the version to 2.0.943
Run npm i [email protected]
package.json”dependencies”: {

“pdfjs-dist”: “^2.0.943”,

},

K8S Error: no metrics known for node [How to Solve]

Today, after deploying metrics server, I checked the pod log and found a pile of errors:

The error information is as follows:

]# kubectl  logs -f -n kube-system            metrics-server-d8669575f-xl6mw
I1202 09:09:31.217954       1 serving.go:312] Generated self-signed cert (apiserver.local.config/certificates/apiserver.crt, apiserver.local.config/certificates/apiserver.key)
I1202 09:09:37.725863       1 secure_serving.go:116] Serving securely on [::]:443
E1202 09:09:49.807117       1 reststorage.go:135] unable to fetch node metrics for node "master": no metrics known for node
E1202 09:09:49.807185       1 reststorage.go:135] unable to fetch node metrics for node "node1": no metrics known for node
E1202 09:09:49.807202       1 reststorage.go:135] unable to fetch node metrics for node "node2": no metrics known for node
E1202 09:09:50.940606       1 reststorage.go:160] unable to fetch pod metrics for pod linux40/nginx-deployment-7d8599fbc9-68pf8: no metrics known for pod
E1202 09:09:53.825493       1 reststorage.go:135] unable to fetch node metrics for node "node1": no metrics known for node
E1202 09:09:53.825540       1 reststorage.go:135] unable to fetch node metrics for node "node2": no metrics known for node
E1202 09:09:53.825551       1 reststorage.go:135] unable to fetch node metrics for node "master": no metrics known for node
E1202 09:10:05.976306       1 reststorage.go:160] unable to fetch pod metrics for pod linux40/nginx-deployment-7d8599fbc9-68pf8: no metrics known for pod
E1202 09:10:21.291923       1 reststorage.go:160] unable to fetch pod metrics for pod linux40/nginx-deployment-7d8599fbc9-68pf8: no metrics known for pod
E1202 09:10:31.601208       1 reststorage.go:135] unable to fetch node metrics for node "master": no metrics known for node
E1202 09:10:31.601330       1 reststorage.go:135] unable to fetch node metrics for node "node1": no metrics known for node
E1202 09:10:31.601353       1 reststorage.go:135] unable to fetch node metrics for node "node2": no metrics known for node
E1202 09:10:31.610963       1 reststorage.go:160] unable to fetch pod metrics for pod kube-system/kube-flannel-ds-64qdh: no metrics known for pod
E1202 09:10:31.611032       1 reststorage.go:160] unable to fetch pod metrics for pod linux40/magedu-tomcat-app1-deployment-6cd664c5bd-wprjb: no metrics known for pod

No valid error message was found when viewing the details of pod

]# kubectl  describe pod metrics-server-6c97c89fd5-j2rql -n kube-system
Name:                 metrics-server-6c97c89fd5-j2rql
Namespace:            kube-system
Priority:             2000000000
Priority Class Name:  system-cluster-critical
Node:                 node2/192.168.64.112
Start Time:           Thu, 02 Dec 2021 16:50:50 +0800
Labels:               k8s-app=metrics-server
                      pod-template-hash=6c97c89fd5
Annotations:          <none>
Status:               Running
IP:                   10.244.2.61
IPs:
  IP:           10.244.2.61
Controlled By:  ReplicaSet/metrics-server-6c97c89fd5
Containers:
  metrics-server:
    Container ID:  docker://eac4a2db02ca75315047eb778b7d3e1d7543d10ed6d33b4b1eddb006f824e34e
    Image:         mirrorgooglecontainers/metrics-server-amd64:v0.3.6
    Image ID:      docker://sha256:9dd718864ce61b4c0805eaf75f87b95302960e65d4857cb8b6591864394be55b
    Port:          4443/TCP
    Host Port:     0/TCP
    Args:
      --cert-dir=/tmp
      --secure-port=4443
      --kubelet-preferred-address-types=InternalIP
      --kubelet-use-node-status-port
      --kubelet-insecure-tls
    State:          Waiting
      Reason:       CrashLoopBackOff
    Last State:     Terminated
      Reason:       Error
      Exit Code:    2
      Started:      Thu, 02 Dec 2021 16:51:10 +0800
      Finished:     Thu, 02 Dec 2021 16:51:11 +0800
    Ready:          False
    Restart Count:  2
    Liveness:       http-get https://:https/livez delay=0s timeout=1s period=10s #success=1 #failure=3
    Readiness:      http-get https://:https/readyz delay=0s timeout=1s period=10s #success=1 #failure=3
    Environment:    <none>
    Mounts:
      /tmp from tmp-dir (rw)
      /var/run/secrets/kubernetes.io/serviceaccount from metrics-server-token-4xrbc (ro)
Conditions:
  Type              Status
  Initialized       True
  Ready             False
  ContainersReady   False
  PodScheduled      True
Volumes:
  tmp-dir:
    Type:       EmptyDir (a temporary directory that shares a pod's lifetime)
    Medium:
    SizeLimit:  <unset>
  metrics-server-token-4xrbc:
    Type:        Secret (a volume populated by a Secret)
    SecretName:  metrics-server-token-4xrbc
    Optional:    false
QoS Class:       BestEffort
Node-Selectors:  <none>
Tolerations:     node.kubernetes.io/not-ready:NoExecute for 300s
                 node.kubernetes.io/unreachable:NoExecute for 300s
Events:
  Type     Reason     Age                From               Message
  ----     ------     ----               ----               -------
  Normal   Scheduled  <unknown>          default-scheduler  Successfully assigned kube-system/metrics-server-6c97c89fd5-j2rql to node2
  Normal   Pulled     16s (x3 over 34s)  kubelet, node2     Container image "mirrorgooglecontainers/metrics-server-amd64:v0.3.6" already present on machine
  Normal   Created    16s (x3 over 34s)  kubelet, node2     Created container metrics-server
  Normal   Started    16s (x3 over 34s)  kubelet, node2     Started container metrics-server
  Warning  BackOff    8s (x5 over 32s)   kubelet, node2     Back-off restarting failed container

Because the CA certificate does not sign the IP of each node when deploying the cluster, when the metrics server requests through IP, it will prompt that the signed certificate does not have a corresponding IP (error: x509: cannot validate certificate for 192.168.33.11 because it doesn’t contain any IP SANS),

We can add a — kubelet secure TLS parameter to skip certificate verification:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: metrics-server
  namespace: kube-system
  labels:
    k8s-app: metrics-server
spec:
  selector:
    matchLabels:
      k8s-app: metrics-server
  template:
    metadata:
      name: metrics-server
      labels:
        k8s-app: metrics-server
    spec:
      serviceAccountName: metrics-server
      volumes:
      - name: tmp-dir
        emptyDir: {}
      containers:
      - name: metrics-server
        image: mirrorgooglecontainers/metrics-server-amd64:v0.3.6
        imagePullPolicy: IfNotPresent
        command:
        - /metrics-server
        - --kubelet-insecure-tls  //skip tls
        - --kubelet-preferred-address-types=InternalIP  //Using internal IP communication
        volumeMounts:
        - name: tmp-dir
          mountPath: /tmp
        resources:
          limits:
            cpu: 300m
            memory: 200Mi
          requests:
            cpu: 200m
            memory: 100Mi

[Solved] ***\npm\node modules\npm\node modul es losenv losenv. js :49: 13

\npm\node modules \npm \node modul es losenv losenv. js :49: 13

I can’t find the package. I deleted the NPM from node, so I can’t find it. Just reinstall it

It’s definitely not possible to reinstall node. Let’s go directly to the official website to compress the package https://nodejs.org/en/download/

Select: Windows binary (.Zip), download and unzip it, and move the NPM folder to the location of the error prompt

[Solved] Vue router in the element UI navigation bar repeatedly clicks on the menu above version 3.0 and reports errors

Add the following code to the index.js file under the router folder:

import Router from 'vue-router'

// Solve the problem that vue-router in the navigation bar of ElementUI reports an error when repeatedly clicking the menu in version 3.0 or above

const originalPush = Router.prototype.push
Router.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}

[Solved] Vue Install Less Error: npm ERR! code ERESOLVE

1. An error occurs when installing less because the installed version is too high

npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR! 
npm ERR! While resolving: [email protected]
npm ERR! Found: [email protected]       
npm ERR! node_modules/webpack        
npm ERR!   dev webpack@"^3.6.0" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer webpack@"^5.0.0" from [email protected]
npm ERR! node_modules/less-loader
npm ERR!   less-loader@"*" from the root project
npm ERR! 
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR!
npm ERR! See C:\Users\59129\AppData\Local\npm-cache\eresolve-report.txt for a full report.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\59129\AppData\Local\npm-cache\_logs\2021-03-19T09_05_44_385Z-debug.log

2. Error reason less this version is too high. You need to reduce the version and execute the code

Remove the previous version first: NPM uninstall less loader
download the specified version: NPM install less- [email protected] -D

3. Just restart the code. If an error is still reported, the file node can be removed_Modules, Download cnpm install again

[Solved] Vue installs less Error: Failed to compile with 1 errors

1. Install less after creating the vue project, execute npm install less less-loader –save-dev
The download version is: [email protected], [email protected], restart the service and report an error, the error message is as follows:

2. The reason for the error is less. The version is too high and the version needs to be lowered to execute the code.
Remove the previous version first:

 

npm uninstall less-loader

Download the specified version:

npm install [email protected] -D

3. Restart the code, if you still report an error, you can remove the file node_modules and download cnpm install again
Supplementary knowledge: Vue project operation error: 94% asset optimization ERROR Failed to compile with 2 errors 13:03:01 error in ./src/ba
The front-end project written using vue reports an error:

88% hashing
89% module assets processing
90% chunk assets processing
94% asset optimization ERROR Failed to compile with 2 errors13:03:01
error in ./src/base/components/head.vue
Module build failed: Error: Node Sass does not yet support your current environment: Windows 64-bit with Unsupported runtime (72)
For more information on which environments are supported please see:
https://github.com/sass/node-sass/releases/tag/v4.7.2
at module.exports (F:\teach\xcEdu\xcEduUI01\xc-ui-pc-sysmanage\node_modules\node-sass\lib\binding.js:13:13)
at Object.<anonymous> (F:\teach\xcEdu\xcEduUI01\xc-ui-pc-sysmanage\node_modules\node-sass\lib\index.js:14:35)
at Module._compile (internal/modules/cjs/loader.js:1156:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1176:10)
at Module.load (internal/modules/cjs/loader.js:1000:32)
at Function.Module._load (internal/modules/cjs/loader.js:899:14)
at Module.require (internal/modules/cjs/loader.js:1042:19)
at require (internal/modules/cjs/helpers.js:77:18)
at Object.<anonymous> (F:\teach\xcEdu\xcEduUI01\xc-ui-pc-sysmanage\node_modules\sass-loader\lib\loader.js:3:14)
at Module._compile (internal/modules/cjs/loader.js:1156:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1176:10)
at Module.load (internal/modules/cjs/loader.js:1000:32)
at Function.Module._load (internal/modules/cjs/loader.js:899:14)
at Module.require (internal/modules/cjs/loader.js:1042:19)
at require (internal/modules/cjs/helpers.js:77:18)
at loadLoader (F:\teach\xcEdu\xcEduUI01\xc-ui-pc-sysmanage\node_modules\loader-runner\lib\loadLoader.js:13:17)

@ ./node_modules/vue-style-loader!./node_modules/css-loader?{“sourceMap”:false}!./node_modules/vue-loader/lib/style-compiler?{“vue”:true,”id”:”data-v-1340bee1″,”scoped”:true,”hasInlineConfig”:false}!./node_modules/sass-loader/lib/loader.js?{“sourceMap”:false}!./node_modules/vue-loader/lib/selector.js?type=styles&index=0&bustCache!./src/base/components/head.vue 4:14-395 13:3-17:5 14:22-403
@ ./src/base/components/head.vue
@ ./node_modules/babel-loader/lib!./node_modules/vue-loader/lib/selector.js?type=script&index=0&bustCache!./src/module/home/page/home.vue
@ ./src/module/home/page/home.vue
@ ./src/module/home/router/index.js
@ ./src/base/router/index.js
@ ./src/main.js
@ multi (webpack)-dev-server/client?http://localhost:11000 webpack/hot/dev-server ./src/main.js

error in ./src/module/home/page/home.vue

Module build failed: Error: Node Sass does not yet support your current environment: Windows 64-bit with Unsupported runtime (72)
For more information on which environments are supported please see:
https://github.com/sass/node-sass/releases/tag/v4.7.2
at module.exports (F:\teach\xcEdu\xcEduUI01\xc-ui-pc-sysmanage\node_modules\node-sass\lib\binding.js:13:13)
at Object.<anonymous> (F:\teach\xcEdu\xcEduUI01\xc-ui-pc-sysmanage\node_modules\node-sass\lib\index.js:14:35)
at Module._compile (internal/modules/cjs/loader.js:1156:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1176:10)
at Module.load (internal/modules/cjs/loader.js:1000:32)
at Function.Module._load (internal/modules/cjs/loader.js:899:14)
at Module.require (internal/modules/cjs/loader.js:1042:19)
at require (internal/modules/cjs/helpers.js:77:18)
at Object.<anonymous> (F:\teach\xcEdu\xcEduUI01\xc-ui-pc-sysmanage\node_modules\sass-loader\lib\loader.js:3:14)
at Module._compile (internal/modules/cjs/loader.js:1156:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1176:10)
at Module.load (internal/modules/cjs/loader.js:1000:32)
at Function.Module._load (internal/modules/cjs/loader.js:899:14)
at Module.require (internal/modules/cjs/loader.js:1042:19)
at require (internal/modules/cjs/helpers.js:77:18)
at loadLoader (F:\teach\xcEdu\xcEduUI01\xc-ui-pc-sysmanage\node_modules\loader-runner\lib\loadLoader.js:13:17)

The reason for the error is that sass does not support the current environment, so just reinstall it in the current environment.
1. Check the version number of local nodejs and node-sass
node -v —Check the version number of nodejs and check whether it is installed
node-sass -v —Check the version number of node-sass and check whether it is installed
2. Uninstall node-sass, but if the uninstallation is unsuccessful, directly find the node-sass folder and delete it
npm uninstall –save node-sass –Remember that before executing this command, you need to enter the corresponding file directory before you can delete
As shown in the figure (as shown below):

3. Reinstall the updated version of node-sass

npm install –save node-sass (cnpm install –save node-sass )

(This should also be executed in the specified folder and installed locally)
that’s it! ! ! ! ! ! ! ! !
As shown below:

[Solved] vue-elemnt-admin npm run dev Run Error

Vue elemnt admin NPM run dev run error

Description:

vue-element-admin 4.4.4

There is the previous Vue element admin template in the computer, which can run normally, but the following error will be prompted when pulling the latest version

Error content

 DONE  Compiled successfully in 4163ms                                                                                                            4:26:31 ├F10: PM┤


  App running at:
  - Local:   http://localhost:9528
  - Network: http://192.168.70.192:9528

  Note that the development build is not optimized.
  To create a production build, run npm run build.

events.js:291
      throw er; // Unhandled 'error' event
      ^

Error: spawn cmd ENOENT
    at Process.ChildProcess._handle.onexit (internal/child_process.js:267:19)
    at onErrorNT (internal/child_process.js:469:16)
    at processTicksAndRejections (internal/process/task_queues.js:84:21)
Emitted 'error' event on ChildProcess instance at:
    at Process.ChildProcess._handle.onexit (internal/child_process.js:273:12)
    at onErrorNT (internal/child_process.js:469:16)
    at processTicksAndRejections (internal/process/task_queues.js:84:21) {
  errno: 'ENOENT',
  code: 'ENOENT',
  syscall: 'spawn cmd',
  path: 'cmd',
  spawnargs: [ '/c', 'start', '""', '/b', 'http://localhost:9528' ]
}

Solution:

Comment out open: true in vue.config.js

Method source:

GitHub community issues

Description of the modified part

vueFor the project, find the devServer configuration proxy in vue.config.js
 
  devServer: {
    port: 8081, // port
    // open: true, // Whether to automatically open the browser
    overlay: {
      warnings: false,
      errors: true
    },
    hot: true, //When simply set to true, if a compilation error is reported, an error will be thrown, and if you change it to the correct one, recompiling will be triggered at this time, and the entire browser will be refreshed!
    headers: {
      'Access-Control-Allow-Origin':'*', //Allow all domain names to access
      'Access-Control-Allow-Credentials':'true' //Whether subsequent requests are allowed to carry authentication information (cookies), this value can only be true, otherwise it will not return
    },
    host: '0.0.0.0',
    proxy: {// proxy
      '/admin': {
        target:'http://192.168.1.100:8080', // background port address
        changeOrigin: true, // The option of virtual hosting website based on name. If not configured, the request will report 404. If the interface is cross-domain, this parameter configuration is required
        ws: true, // true/false, whether to proxy websockets
        secure: false, // If it is an https interface, this parameter needs to be configured
        pathRewrite: {
          '^/admin':'' //pathRewrite is to redirect the request path to match the correct request address when proxy is used for proxy
        }
      }
    }
  }

Description information original blog address

Layui use customselect Error: the customselect.js of the requested item cannot be found, 404

It appears when using the code of a drop-down selection box found on the Internet in layui,

The JS in the folder cannot be found is displayed. After reading the error request path, there are two more folders. The path in layui.config is written at the same level as in script. I think this path is OK

Later, the path in the config base tried to.. /.. /. The superior of the superior found the JS file correctly.

This problem is actually a path problem. Let’s see if there are more levels.