Category Archives: Javasript

[Solved] Node.js: Python not found exception due to node-sass and node-gyp

Node.js: Python not found exception due to node-sass and node-gyp
Solution 1:
so this happened to me on windows recently. I fix it by following the following steps using a PowerShell with admin privileges:
deletenode_modules folder
running npm install --global windows-build-tools with administrative privilege. (in my case need restart – and restart without ask!!!)
reinstalling node modules or node-sass with npm install
This is exactly the right answer. npm install --global windows-build-tools installs Python 2.7, and installs it globally (so you don’t have to re-install on a per-project basis). It fixes the “can’t install SASS” problem. NOTE: On windows, you must run your npm command prompt as “Administrator”.
– paulsm4
Nov 22 ’18 at 22:14

 

 

Solution 2:

The error message means that it cannot locate your python executable or binary.
In many cases, it’s installed at c:\python27. if it’s not installed yet, you can install it with npm install --global windows-build-tools, which will only work if it hasn’t been installed yet.
Adding it to the environment variables does not always work. A better alternative, is to just set it in the npm config.
npm config set python c:\python27\python.exe

[Solved] Property ‘install’ is missing in type ‘{ new (): Plugin; prototype: Plugin; }’ but required in type ‘PluginObject

The error information is as follows:

1m[31mERROR in /var/lib/jenkins/workspace/CICD-libya-admin/src/main.ts[39m[22m
[2m59:9[22m No overload matches this call.
  Overload 1 of 2, '(plugin: PluginObject<unknown> | PluginFunction<unknown>, options?: unknown): VueConstructor<Vue>', gave the following error.
    Argument of type '{ new (): Plugin; prototype: Plugin; }' is not assignable to parameter of type 'PluginObject<unknown> | PluginFunction<unknown>'.
      Property 'install' is missing in type '{ new (): Plugin; prototype: Plugin; }' but required in type 'PluginObject<unknown>'.
  Overload 2 of 2, '(plugin: PluginObject<any> | PluginFunction<any>, ...options: any[]): VueConstructor<Vue>', gave the following error.
    Argument of type '{ new (): Plugin; prototype: Plugin; }' is not assignable to parameter of type 'PluginObject<any> | PluginFunction<any>'.
      Property 'install' is missing in type '{ new (): Plugin; prototype: Plugin; }' but required in type 'PluginObject<any>'.

After analyzing the error message, it should be caused by the inconsistent ts type. However, it was normal locally. After deleting node_modules and running again, the local error was exactly the same as the test environment.Then, open vs Code and find the Src/main.TS file to view. An error was found in the following code.

The type of vue.use method is:

The type of vuecompositionapi is:

Preliminary inference: Both .ts files are included in node_modules, so the problem should lie in the version. So go to https://www.npmjs.com/ and  search for @vue/composition-api.

It was found that the last release was a day ago, and the last successful build of Jenkins was on November 12th. Is it because we downloaded the latest version and caused the incompatibility?
With doubts, I opened the @vue/composition-api/package.json file in node_modules to view it, and sure enough, I downloaded the latest version.

New question: isn’t the old version number defined in package.json? Why download to the latest version?

With questions, I searched the Internet for “how to lock the dependent version defined in package.json” and found a solution
NPM shrinkwrap can lock the dependent version defined in package.json
after execution, the npm-shrinkwrap.json file can be generated. With this file, we are not afraid that NPM and cnpm will download the latest version of dependencies to us.

Mac installation NPM install – G @Vue/cli error [How to Solve]

An error is reported when installing NPM install – G @Vue/cli on the Mac. The version is too high. Please solve with the follow code:

sudo chown -R $(whoami) /usr/local/*

Error reason: insufficient permissions

Solution:

Open the terminal and enter sudo - s

Enter your password

Create a folder to hold items. Use the CD command to switch to the directory location

[Solved] NPM downloads the dependency of the front-end Vue admin template master template Error

The front end uses Vue admin template master. When using NPM to download dependencies, errors are always reported

When I first used Vue admin template master, it was a video resource. The result was an error, which Baidu couldn’t find out. I don’t think it’s possible that I went to the official website to download because the version is old. I really solved some bugs, but it’s not enough. The error reports are as follows

error code 1
error path F:\webstrom项目\SpringBoot大项目实战\vue-admin-template-master\node_modules\deasync
error command failed
error command C:\WINDOWS\system32\cmd.exe /d /s /c node-gyp rebuild
error gyp info it worked if it ends with ok
error gyp info using [email protected]
error gyp info using [email protected] | win32 | x64
error gyp info find Python using Python version 3.7.7 found at "C:\Users\asus\AppData\Local\Programs\Python\Python37\python.exe"
error gyp ERR! find VS
error gyp ERR! find VS msvs_version not set from command line or npm config
error gyp ERR! find VS VCINSTALLDIR not set, not running in VS Command Prompt
error gyp ERR! find VS could not use PowerShell to find Visual Studio or newer, try re-running with '--loglevel silly' for more details
error gyp ERR! find VS looking for Visual Studio 2015
error gyp ERR! find VS - not found
error gyp ERR! find VS not looking for VS2013 as it is only supported up to Node.js 8
error gyp ERR! find VS
error gyp ERR! find VS **************************************************************
9800 error gyp ERR! find VS You need to install the latest version of Visual Studio
9800 error gyp ERR! find VS including the "Desktop development with C++" workload.
9800 error gyp ERR! find VS For more information consult the documentation at:
error gyp ERR! find VS https://github.com/nodejs/node-gyp#on-windows
error gyp ERR! find VS **************************************************************
error gyp ERR! find VS
error gyp ERR! configure error
error gyp ERR! stack Error: Could not find any Visual Studio installation to use
error gyp ERR! stack     at VisualStudioFinder.fail (C:\Users\asus\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:121:47)
error gyp ERR! stack     at C:\Users\asus\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:74:16
error gyp ERR! stack     at VisualStudioFinder.findVisualStudio2013 (C:\Users\asus\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:351:14)
error gyp ERR! stack     at C:\Users\asus\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:70:14
error gyp ERR! stack     at C:\Users\asus\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:372:16
error gyp ERR! stack     at C:\Users\asus\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\lib\util.js:54:7
error gyp ERR! stack     at C:\Users\asus\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\lib\util.js:33:16
error gyp ERR! stack     at ChildProcess.exithandler (node:child_process:404:5)
error gyp ERR! stack     at ChildProcess.emit (node:events:390:28)
error gyp ERR! stack     at maybeClose (node:internal/child_process:1064:16)
error gyp ERR! System Windows_NT 10.0.19042
error gyp ERR! command "D:\\node.js\\node.exe" "C:\\Users\\asus\\AppData\\Roaming\\npm\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
9800 error gyp ERR! cwd F:\webstrom项目\SpringBoot大项目实战\vue-admin-template-master\node_modules\deasync
error gyp ERR! node -v v16.13.0
error gyp ERR! node-gyp -v v8.3.0
error gyp ERR! not ok
verbose exit 1

Google found out that the version of node.js is too high and should be reduced. I downloaded the stable version of the official website. I don’t want to reduce the version.

**************************************************************
9800 error gyp ERR! find VS You need to install the latest version of Visual Studio
9800 error gyp ERR! find VS including the "Desktop development with C++" workload.
9800 error gyp ERR! find VS For more information consult the documentation at:
error gyp ERR! find VS https://github.com/nodejs/node-gyp#on-windows
error gyp ERR! find VS **************************************************************

Problem solving: download the latest version of visual studio. I downloaded visual studio 2019

 

How to Solve “Fibers is not supported” Error in Nodejs V16.X or Higher Version

Assertion failed
Expression:thread_id_key ! = 0x7777
For information on how your program can cause an assertion failure,see the visual C++ documentation on asserts
(Press Retry to debug the application – JIT must be enabled)

Cause: nodejs v16.x or higher does not support Fibers

Solution: Download nvm Download version 14 of node currently will not report errors

Axios encapsulate error: cyclic dependency [How to Solve]

When NPM starts, an error is directly reported: cyclic dependency

You can read the above blog to find out what this mistake is about

Let’s start my solution now (for Vue, please draw inferences from others)

In main.js

import axios from './util/ajax'
// Registering components to Vue
Vue.prototype.$axios = axios

Then where you need to send a request

Just use this. $Axios. Get instead of Axios. Get

Vue3’s use of reactive/torefs + V-model leads to the failure of response and the failure of El form input

1. Problem background

When using the El form in vue3, the following code will cause the input box to be unable to input, the value cannot be assigned, and the selection box cannot be selected

<el-form ref="service" :model="service" label-width="80px">
    <el-form-item label="NAME">
      <el-input v-model="service.name"></el-input>
    </el-form-item>
    ......
</el-form>

setup() {
  const state = reactive({
    service: {
      name: '**'
    }
  })
  return {
    ...toRefs(state)
  }
}

The repetition of the name of the response variable declared by ref component instance and ref() will lead to the invalidation of the response. Any form content of the form cannot be entered, and an error will be reported: uncaught (in promise) typeerror: cannot read property ‘name’ of undefined, etc

2. Problem causes and Solutions

This problem arises because the ref naming is the same as the model. The reason is that El form declares ref = “service”, which causes the service declared in state to be overwritten, and the two conflict.

Modify the name (such as ref = “serviceform” or model = “serviceinfo”) to solve the problem.