Tag Archives: front end

Vuex Use Prettier – Code formatter to format errors [How to Solve]

In using vuex, the prettier – code formatter is downloaded and Automatic formatting requires the following configuration

Need to create .prettierrc in the root directory of the file for configuration

{

  "semi": false,

  "singleQuote": true,

  "trailingComma": "none"

}

Using eslint according to the error report

.eslintrc.js

Add commands in rules

You can ignore the space before the function

 rules: {
    'no-console': process.env.NODE_ENV === 'production' ?'error' : 'off',
    'no-debugger': process.env.NODE_ENV === 'production' ?'error' : 'off',
    'space-before-function-paren': 0
  },

[Solved] ESLint error: Newline required at end of file but not found (eol-last)

When verifying Vue projects with eslint, the following warnings were found:

error: Newline required at end of file but not found (eol-last)

The results are as follows:

I found that the online solution is to insert a blank line after the warning code. I think this is very bad.

[solution]
1. Insert a configuration file .Editorconfig , in the project_final_Newline = true is changed to false

2. Cancel the verification of the last rule in . Eslintrc. JS

recompile without warning.

Hadoop ERROR: Attempting to operate on hdfs namenode as root ERROR: but there is no HDFS_NAMENODE_US

In the sbin directory under the hadoop installation directory, respectively modify /start-dfs.sh /stop-dfs.sh /start-yarn.sh /stop-yarn.shThe content of the modified file should be added in the file #!/usr/bin/env bash

/start-dfs.sh /stop-dfs.sh Modified content (HADOOP_SECURE_DN_USER is replaced by HADOOP_SECURE_DN_USER.) above hadoop 3.2 version.)

HDFS_DATANODE_USER=root
HADOOP_SECURE_DN_USER=hdfs
HDFS_NAMENODE_USER=root
HDFS_SECONDARYNAMENODE_USER=root

/start-yarn.sh  /stop-yarn.sh Modify content

YARN_RESOURCEMANAGER_USER=root
HADOOP_SECURE_DN_USER=yarn
YARN_NODEMANAGER_USER=root

[Solved] Vue Use gzip Package Error: Rule can only have one resource source

How to configure:

NPM I compression webpack plugin - d install the plug-in and add the following configuration in Vue.Config.JS (the compression plugin configuration options depend on your personal needs)

configureWebpack: {
	plugins: [
		new CompressionPlugin({
			test: /\.(js|css)?$/i, // Which files to compress
                        algorithm:'gzip', // Use gzip compression
		})
	]
}

Problems:
usegzip to unzip the Vue project report an error:Error: Rule can only have one resource source (provided resource and test + include + exclude).
Cause Analysis:
Webpack version conflict in package.json

Solution:
npm i [email protected] -D
npm i [email protected] [email protected] -D

[Solved] SyntaxError: Cannot use import statement outside a module

Solve the syntaxerror: cannot use import statement outside a module problem

Originally, I wanted to test blob and format in the node environment. After importing relevant JS files, an error cannot use import statement outside a module occurs. Here are the following references to solve the problem:

    1. use commonjs syntax to bypass import
let Blob = require('blob-polyfill/Blob');

It can solve the problem of failed file import at present, but it means that you can’t use import to import in the future. The fundamental problem has not been solved. Of course, this is not my style. Then go to consult the data. What the elder brother said is well summarized as follows:

The error is reported because the node environment does not support ES6 syntax. We can install Babel jest, @Babel/core, @Babel/preset env to solve the problem (these plug-ins can convert ES6 code into Es5 so that the node environment can be recognized. Here I choose @Babel/preset env for installation). After installation, create babel.config.js file in the root log of the project: see the name of this file, Babel is configured; (similar to webpack.Config.JS),

module.exports = {
    "presets": [
        ["@babel/preset-env",
            {
                "targets":
                    { "node": true }
            }
        ]
    ]
}

Generally speaking, package.json is not configured with type, and it is equipped with type: type: "module". The problem is solved here. Finally, I also remembered that when I first used sass, I had to configure it to compile sass into CSS and be recognized by the environment (Longyin).

Node.js Error: “Error: EBUSY: resource busy or locked, stat“

abnormal

Error: EBUSY: resource busy or locked, stat 'C:\swapfile.sys'
    at Object.statSync (node:fs:1536:3)
    at D:\NodeJs\node-demo\demo\world.js:7:24
    at FSReqCallback.oncomplete (node:fs:188:23) {
  errno: -4082,
  syscall: 'stat',
  code: 'EBUSY',
  path: 'C:\\swapfile.sys'
}

Node.js v17.1.0

error code

var fs = require('fs');

var rootPath = 'C:\\';
fs.readdir(rootPath, function (err, files) {
    for (var i = 0; i < files.length; i++) {
        var p = rootPath + files[i];
        var stats = fs.statSync(p);
        console.log(rootPath + 'Is it a directory:' + stats.isDirectory())
    }
});

Reason

Prompt error: EBUSY: resource busy or locked, stat indicates that the resource file is busy or locked, that is, the C:\swapfile.Sys file. But there is no such file in the C disk directory, even in the hidden file. But it can be found by opening everything software
is a system file.

Solution:

I don’t know how to solve it. The online solution seems to be invalid, so I can only block the file.

Correct code

var fs = require('fs');

var rootPath = 'C:\\';
fs.readdir(rootPath, function (err, files) {
    for (var i = 0; i < files.length; i++) {
        var p = rootPath + files[i];
        // Skip when encountering swapfile.sys file or System Volume Information directory
        if (p.endsWith('swapfile.sys') || p.endsWith('System Volume Information')) {
            continue;
        }
        var stats = fs.statSync(p);
        console.log(rootPath + 'Is it a directory:' + stats.isDirectory())
    }
});

[Solved] Syntax Error: Error: Cannot find module ‘cache-loader‘

The following problem occurs. It should be that some dependent packages are not downloaded successfully and need to be reinstalled

Solution:
1. Enter the folder directory of the project and delete the node_ Modules file and package-lock.json file. Note that it is not package.json (if it cannot be deleted, check whether the project is open and try again after closing)
2. Enter NPM install installation dependency

3. Start the project and it can be started normally.

Error: Duplicate plugin/preset detected [How to Solve]

Reason: element UI in .Babel is repeated

Solution: remove duplicate code in babel.config.js

Before modification

module.exports = {
  "presets": [
    "@vue/cli-plugin-babel/preset"
  ],
  "plugins": [
    [
      "component",
      {
        "libraryName": "element-ui",
        "styleLibraryName": "theme-chalk"
      }
    ],
    [
      "component",
      {
        "libraryName": "element-ui",
        "styleLibraryName": "theme-chalk"
      }
    ]
  ]
}

After modification

module.exports = {
  "presets": [
    "@vue/cli-plugin-babel/preset"
  ],
  "plugins": [
    [
      "component",
      {
        "libraryName": "element-ui",
        "styleLibraryName": "theme-chalk"
      }
    ]
  ]
}