Tag Archives: node.js

[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.

How to Solve Vue cli configuration SCSS global variable error

It is configured according to the online tutorial, but it still reports errors. The error information is as follows:

Module build failed (from ./node_modules/sass-loader/dist/cjs.js):

    width: $sideBarWidth !important;
          ^
      Undefined variable: "$sideBarWidth".

Baidu has a problem with the version of SASS loader
// in sass version 9, additionaldata is used, in sass version 8, prependdata is used, and in other versions, data
my version is 7.1.0, so finally changing the key name to data solves the problem

in vue.config.js, the configuration is as follows:

module.exports = {
    ...
	css: {
	  //   extract: true // Whether to use the css separation plugin ExtractTextPlugin (open skeleton screen must be this configuration)
	    // css presetter configuration item
	    // use additionalData in sass version 9 use prependData in version 8, other versions, use data
	    // semicolon here; required
	    loaderOptions: {
	      sass: {
	        data: '@import "./src/styles/variables.scss";'
	      }
	    },
	  },
	 ...
},

Note: semicolon after the configuration file path; Media query expression must begin with ‘(‘

The toast light prompt of vant in Vue reports an error

Toast light prompt for using vant component library in Vue

Record the toast light prompt in vant today, and use it according to the methods in the official documents. It can’t be used if an error is found
this is what the document says

Toast.success('success');
Toast.fail('fail');

After referencing vant in main.js, directly call toast to report an error
the actual usage is as follows:

this.$toast.success("success");
this.$toast.fail("fail");

Like calling routing, you need to click this.

[Solved] Npm -v Error: Cannot find module npm_cli

1. If you download the upgraded node version from the node official website, the package management NPM will be automatically installed

2. If you install the NVM and then upgrade or downgrade the node version, the NPM is not automatically installed at this time   As shown in the figure, my node 12.10.0 is downloaded from the official website and 10.15.3 is managed by NVM. After switching back, the NPM will not report an error

An error is reported when using react app rewired to start the react project

An error is reported when using react app rewired to start the react project

The error contents are as follows:

 

The “injectbabelplugin” helper has been deprecated as of v2.0

The new version of react app rewired removes the injectbabelplugin, and these methods are moved to a new package called ‘Customize CRA’

Solution:
reduce react app rewired to version 2.0

npm uninstall react-app-rewired

Delete the original react app rewired with the above statement

npm i [email protected]

Then reinstall the lower version of react app rewired

Front end project construction error unexpected character ‘@’ solution

After I imported the CSS file of bootstrap, the following error messages appeared in the construction project:

ERROR in ./src/util/bootstrap/bootstrap.min.css
Module parse failed: D:\eclipseWorkspace\mbos\mbos-portal\webContent\src\util\bootstrap\bootstrap.min.css Unexpected character '@' (1:0)
You may need an appropriate loader to handle this file type.
SyntaxError: Unexpected character '@' (1:0)
    at Parser.pp$4.raise (D:\eclipseWorkspace\mbos\mbos-portal\webContent\node_modules\webpack\node_modules\acorn\dist\acorn.js:2221:15)
    at Parser.pp$7.getTokenFromCode (D:\eclipseWorkspace\mbos\mbos-portal\webContent\node_modules\webpack\node_modules\acorn\dist\acorn.js:2756:10)
    at Parser.pp$7.readToken (D:\eclipseWorkspace\mbos\mbos-portal\webContent\node_modules\webpack\node_modules\acorn\dist\acorn.js:2477:17)
    at Parser.pp$7.nextToken (D:\eclipseWorkspace\mbos\mbos-portal\webContent\node_modules\webpack\node_modules\acorn\dist\acorn.js:2468:15)

The reason is that the CSS file contains the @ symbol, and the configuration file does not specify a loader for the CSS file,

Solution: specify loader for CSS file:


{ 
	test: /\.css$/,
	loader: 'style-loader!css-loader' 
},

(a)’21442;’32771;65306;
styles.css Unexpected character’

How to Solve “Vue is not defined” Error

Background there is a problem in the introduction of Axios
code

import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import axios from 'axios'


import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
import './reset.css'

Vue.config.productionTip = false
Vue.use(ElementUI);
axios.default.baseURL = 'https://www.fastmock.site/mock/ad1bc58516abb5f0f452402035be2443/houtai'
Vue.prototype.$http = axios

This is because the order of the two lines of code is wrong
change to

import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import axios from 'axios'
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
import './reset.css'
axios.default.baseURL = 'https://www.fastmock.site/mock/ad1bc58516abb5f0f452402035be2443/houtai'
Vue.prototype.$http = axios
Vue.config.productionTip = false
Vue.use(ElementUI);

How to Solve Node GYP Rebuild Error

Node gyp rebuild error handling

Error message:

node-gyp rebuild

  CXX(target) Release/obj.target/contextify/src/contextify.o
../src/contextify.cc:50:53: error: too few arguments to function call, single argument 'context' was not specified
        target->Set(className, ljsTmpl->GetFunction());
                               ~~~~~~~~~~~~~~~~~~~~ ^
/Users/xxx/Library/Caches/node-gyp/14.15.4/include/node/v8.h:6482:46: note: 'GetFunction' declared here
  V8_WARN_UNUSED_RESULT MaybeLocal<Function> GetFunction(
                                             ^
../src/contextify.cc:60:74: error: too few arguments to function call, single argument 'context' was not specified
        ContextifyContext* ctx = new ContextifyContext(info[0]->ToObject());
                                                       ~~~~~~~~~~~~~~~~~ ^
/Users/xxx/Library/Caches/node-gyp/14.15.4/include/node/v8.h:2822:44: note: 'ToObject' declared here
  V8_WARN_UNUSED_RESULT MaybeLocal<Object> ToObject(
                                           ^
../src/contextify.cc:75:48: error: too few arguments to function call, single argument 'context' was not specified
        Local<String> code = info[0]->ToString();
                             ~~~~~~~~~~~~~~~~~ ^
/Users/xxx/Library/Caches/node-gyp/14.15.4/include/node/v8.h:2810:44: note: 'ToString' declared here
  V8_WARN_UNUSED_RESULT MaybeLocal<String> ToString(
                                           ^
../src/contextify.cc:81:51: error: too few arguments to function call, single argument 'context' was not specified
            ScriptOrigin origin(info[1]->ToString());
                                ~~~~~~~~~~~~~~~~~ ^
/Users/xxx/Library/Caches/node-gyp/14.15.4/include/node/v8.h:2810:44: note: 'ToString' declared here
  V8_WARN_UNUSED_RESULT MaybeLocal<String> ToString(
                                           ^
../src/contextify.cc:124:45: error: too few arguments to function call, single argument 'context' was not specified
        constructor.Reset(tmpl->GetFunction());

Solution: switch the node version to node 8.17.0 to solve the above error reports

Mac install to multi version node

1. Download and install
NPM install -g n
2. Download the specified version (followed by the version number)
sudo n 14.15.0
3. Display which versions have been installed
n LS
4. Switch the version used (followed by the version number)
sudo n
view the installed version and switch the version used up and down

[Solved] Vue Error: Module build failed Error Node Sass version 6.0.1 is incompatible with ^4.0.0.

Vue error module build failed: error: node sass version 6.0.1 is incompatible with ^ 4.0.0. Solution

Error message:

 ERROR  Failed to compile with 1 errors                                                                                                                                      下午6:51:57
 
 error  in ./src/views/Login.vue
 
Module build failed: Error: Node Sass version 6.0.1 is incompatible with ^4.0.0.
    at getSassImplementation (D:\IDEA\IDEA Projects\Vue\hello-vue\node_modules\[email protected]@sass-loader\dist\utils.js:77:13)
    at Object.loader (D:\IDEA\IDEA Projects\Vue\hello-vue\node_modules\[email protected]@sass-loader\dist\index.js:34:59)
 
 @ ./node_modules/vue-style-loader!./node_modules/css-loader?{"sourceMap":true}!./node_modules/vue-loader/lib/style-compiler?{"vue":true,"id":"data-v-26084dc2","scoped":true,"hasInline
Config":false}!./node_modules/[email protected]@sass-loader/dist/cjs.js?{"sourceMap":true}!./node_modules/vue-loader/lib/selector.js?type=styles&index=0!./src/views/Login.vue 4:14-389
 13:3-17:5 14:22-397
 @ ./src/views/Login.vue
 @ ./src/router/index.js
 @ ./src/main.js
 @ multi (webpack)-dev-server/client?http://localhost:8080 webpack/hot/dev-server ./src/main.js

Solution:

Find the problem: module build failed: error: node sass version 6.0.1 is incompatible with ^ 4.0.0

This problem is caused by the high version of SASS, so just change the version to the corresponding version according to the prompt. Here, change to version 4.0.0.

Step 1: find the package.json file in the IDE:

Step 2: find sass loader and change its version to 4.0.0

Finally, execute

cnpm install

Finally, execute

cnpm install

npm run dev

Create Vue cli project and report error command failed: Yarn

Create Vue cli project and report error command failed: Yarn

Solution 1:

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 2:

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.


Solution 3: enter CMD in Win + R 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.