Tag Archives: javascript

About JS error uncaught syntax error: invalid shorthand property initializer

Sometimes when typing JS code, you will often encounter such errors:

This is due to careless typing of code, resulting in grammatical format errors.

If the object literal is used to define the object, the relationship between the attribute name and the attribute value:

<script>
var province = [{
            id: 1002,
            name: 'Heibei',
            city: [{
                    id: 1,
                    name= 'Shijiazhuang' // use object literals to define objects with attribute names separated from attribute values by:.
                },
                {
                    id: 2,
                    name: 'Handan'
                }
            ]
        }];
</script>

Grammar norms are very important. Try not to make mistakes that can be avoided.

Vue Project Error: Expected indentation of 2 spaces but found 4,Newline required at end of file but not found

Several error messages were encountered when learning Vue project was packaged

★   Extra semicolon

The first is that there is an additional semicolon. The error query found that main.js does have a semicolon. After we deleted it, the error disappeared

★   Expected indentation of 2 spaces but found 4

The second one is “expected to indent 2 spaces, but found 4”. After Baidu search, it is found that this is not an error, but a check rule. Find this file in the project and add this configuration. See the figure below

★   Newline required at end of file but not found

The third one is more wonderful. It means that “line breaks are required at the end of the file, but they are not found”. Then we go to the error file, that is, main.js. We can solve the error by typing enter at the end. See the figure below

Adding a blank line here can solve the problem of error reporting

How to Solve Nodejs error: cannot find module ‘. /application’

Open the terminal and enter nodemon./index.js. The following error messages appear:

Solution:

After entering the directory where index.js is located
delete node_ Module folder and package lock.json file open the terminal, type NPM clean cache , clear the cache, type NPM I , and type nodemon index. JS  for installation dependency
Run nodemon./index.js again

Perfect solution~

Error when Python executes JavaScript statement

‘gbk’ codec can’t encode character ‘\u20ac’ in position 62114: illegal multibyte sequence
find this line in the JS files:

e = "a€|",

It should be this symbol that reports an error. How to solve it

with open('./encryp_js/eventid_encryp.js', 'r', encoding='utf-8') as f:
    content = f.read()
jsdata = execjs.compile(content)

[Vue warn]: Error in v-on handler: “TypeError: Object(…) is not a function“

The record appears in Vue
[Vue warn]: error in v-on handler: "typeerror: object (...) is not a function"

when referencing an external file, it is only partially referenced, so it was originally referenced in a deconstruction mode. I forgot to add
{}

// Wrong
import loginAPI from '@/api'

// Right
import { loginAPI } from '@/api'

Error command failed when creating vue-cli4 project: Yarn

Error reported when creating Vue item: error command failed: Yarn

Solution 1: Win + R enter CMD to enter the command line interface

Enter command

npm install -g yarn

After success, the problem can be solved by re creating vue-cli4 project.

Solution 2:

Enter C:/users/administrator/in the windows environment

There is a file. Vuerc

 

Open this file to display

{
  "useTaobaoRegistry": true,
  "packageManager": "yarn"
}

Just manually change the configuration content yarn to NPM to change the package manager when the project is created

Solution 3:

Delete the. Vuerc file. When you create a Vue project for the first time, you will be prompted to select the configuration, and then select NPM
 

Module build failed: Error: Node Sass does not yet support your current environment: Windows 64-bit

@[TOC](Module build failed: Error: Node Sass does not yet support your current environment: Windows 64-bit with Unsupported runtime (93))

Importing other people’s Vue projects on gitee or GitHub can easily lead to incompatible node sass versions. Generally, you are prompted as follows:

Module build failed: Error: Node Sass does not yet support your current environment: Windows 64-bit with Unsupported runtime (93)
For more information on which environments are supported please see:
https://github.com/sass/node-sass/releases/tag/v4.12.0

This is the error encountered

We open the web page on the link and find that it is the corresponding version. My node version is 16, which is incompatible

Here, you need to change the version of node sass in package.json to match the notejs Version (emphasis)

On the official website, you can see that my nodejs (16) corresponds to 6.0+

After modification, it is better to delete the previous node sass Version (under the node_medules directory)

Re execute NPM I or cnpm I to re import dependencies

Done!!!

[Solved] ERROR Error: Cannot find module ‘vue-loader-v16/package.json‘

Error Message:
ERROR  Error: Cannot find module ‘vue-loader-v16/package.json’
Error: Cannot find module ‘vue-loader-v16/package.json’
at Function.Module._resolveFilename (module.js:555:15)
at Function.Module._load (module.js:482:25)
at Module.require (module.js:604:17)
at require (internal/module.js:11:18)
at api.chainWebpack.webpackConfig (D:\3\data\dashboard\node_modules\_@[email protected]@@vue\cli-service\lib\config\base.js:114:23)
at webpackChainFns.forEach.fn (D:\3\data\dashboard\node_modules\_@[email protected]@@vue\cli-service\lib\Service.js:236:40)
at Array.forEach (<anonymous>)
at Service.resolveChainableWebpackConfig (D:\3\data\dashboard\node_modules\_@[email protected]@@vue\cli-service\lib\Service.js:236:26)
at Service.resolveWebpackConfig (D:\3\data\dashboard\node_modules\_@[email protected]@@vue\cli-service\lib\Service.js:240:48)
at PluginAPI.resolveWebpackConfig (D:\3\data\dashboard\node_modules\_@[email protected]@@vue\cli-service\lib\PluginAPI.js:132:25)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] serve: `vue-cli-service serve`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] serve script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\lenovo\AppData\Roaming\npm-cache\_logs\2021-09-22T07_50_43_187Z-debug.log
Solution: Execute the following commands:
cnpm i vue-loader-v16

[Solved] Npm install Error: verbose stack Error: unable to resolve dependency tree

[environment]

[email protected]

[email protected]

1. Analysis reason:

After investigation, 1. It is found that there is peer dependency in package.json, indicating the version of angular 7. X, which is incompatible with the version of angular 8. X that the current project depends on, resulting in compilation errors.

2, in addition, the original use of npm 6.x install is no problem, because npm 7.x on peer dependency compatibility requirements are higher, so the error is reported.

2. Solution:

Method 1: — force or — legacy peer DEPs

npm install –force

npm   install –legacy-peer-deps

Method 2:

Modify the dependency definition package.json of the problem component and the component version that peer dependency depends on.

Error: [VueLoaderPlugin Error] No matching use for vue-loader is found. Make sure the rule matching

Project scenario:

using webpck5 package vue3 plug-in to import Vue loader appears

Error: [VueLoaderPlugin Error] No matching use for vue-loader is found. 
Make sure the rule matching .vue files include vue-loader in its use.

terms of settlement:

It can be solved by putting Vue loader in the first place

  module: {
    rules: [
      {
        test: /\.vue$/,
        loader: "vue-loader",
      },

This dependency was not found:* vue-editor-bridge

Error reporting result:

When the project is running, a compilation error occurs suddenly and the dependency cannot be found. Follow the prompt to execute NPM install — save Vue editor bridge, or an error is reported

This dependency was not found:

* vue-editor-bridge in ./node_modules/cache-loader/dist/cjs.js??ref--12-0!./node_modules/babel-loader/lib!./node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/vue-loader/lib??vue-loader-options!./src/components/Test.vue?vue&type=script&lang=js&

To install it, you can run: npm install --save vue-editor-bridge
Error from chokidar (C:\): Error: EBUSY: resource busy or locked, lstat 'C:\DumpStack.log.tmp'

Cause finding:

After finding similar error reports, it is found that vscode automatically adds a line of import, as if it entered func when entering function, and vscode imported func as a component by default (you don’t have to be so smart?)

import func from 'vue-temp/vue-editor-bridge'

Solution:

Just delete this line of code