Tag Archives: node

UnhandledPromiseRejectionWarning: MongoError: not authorized on elm to execute comman

Error in starting node project

UnhandledPromiseRejectionWarning: MongoError: not authorized on elm to execute command { insert: “hongbaos”, ordered: false, $db: “elm” }

The reason is that you do not have permission to connect to the database

The reason is that the database mongo.conf There is an auth = true solution

1. Comment out auth = true

2. Enter adimn to set the user name and password, and use the user name and password to access the database

Switch use admin before creating user


The node rimraf module recursively deletes the contents of the folder

When using the webpack build file project, a dist directory is generated every time. Sometimes, all the old files in the dist directory need to be deleted,

In addition to the RM – RF / dist / command, you can also use the rimraf / dist / command

The function of rimraf is to package the RM - RF command in the form of package to delete files and folders, regardless of whether the folder is empty or not

Local installation: NPM install rimraf — save dev

Global installation: NPM install rimraf – G

Use: rimraf & lt; path & gt; [& lt; path & gt;…]

api:rimraf(f, [opts], callback)

NPM run build error solution

An error is as follows

checked online related:
because package json file does not have to configure the build script, so the above error!
1. Add build script to scripts in package.json:

  "scripts": {
    "build": "cross-env NODE_ENV=production webpack --config webpack.config.js"

“NODE_ENV” : user-defined environment variable
webpack “: integrated packaging command
“>config” : config file
“webpa>onfig.js” : config file, which is a Node. js module that returns a JSIN-formatted configuration information object, or the –config option to specify the configuration file

It is possible that ‘cross-env’ is not an internal or external command and is not a executable program
can be resolved by NPM I –save-dev cross-env.
The results of
Execute NPM run build, and the results will appear in the dist folder. Successful packaging!

Reference: https://www.cnblogs.com/tugenhua0707/p/9780621.html


Node connects to MySQL error “Er”_ NOT_ SUPPORTED_ AUTH_ Mode “solution

Perform the following query in MYSQL Workbench
ALTER USER ‘root’ @’ localhost ‘IDENTIFIED WITH mysql_native_password BY’ password ‘
when root is USER localhost of your url, and password is your password
, then run the following query to flush privileges:
flush privileges;
try using node connections after completion.
if that doesn’t work, try @’ localhost ‘

node url.parse()

Assume that this is a url http://localhost:8080/a/b/c?a=1&
protocol: ‘HTTP:’,// protocol
host: ‘localhost:8080’,
port: ‘8080’,// port
hostname: ‘localhost’, domain
hash: ‘#abcd’,
search: ‘?a=1& B = 2 ‘,
query: ‘a = 1 & amp; B =2 ‘,
pathname: ‘/a/b/c’,
path: ‘/a/b/c?a=1& B = 2 ‘,
href: ‘http://localhost:8080/a/b/c?a=1& B = 2 # ABC ‘
Url.parse () can break a complete URL into many parts, such as host, port, Pathname, path, and Query

var http = require("http");
var url = require("url");

var server = http.createServer(function(req,res){
    var pathname = url.parse(req.url).pathname;
    var query = url.parse(req.url).query;
    console.log("patname:"+ pathname);

Completely uninstall node and NPM on MAC

NVM is installed under ~/. NVM is not installed with the previous one. I am a little obsessive, so I want to uninstall the previous one
Homebrew installed

brew uninstall node
The official website downloads the PKG installation package
A command
sudo rm - rf/usr/local/{bin/{node, NPM}, lib/node_modules/NPM, lib/node, share/man/*/node. *}
It was installed in another way
Make a script, the need to delete the file, a shuttle all kill
It will be called: uninstallNode. sh

lsbom -f -l -s -pf /var/db/receipts/org.nodejs.pkg.bom \
| while read i; do
  sudo rm /usr/local/${i}
sudo rm -rf /usr/local/lib/node \
     /usr/local/lib/node_modules \

Modify file permissions chmod 777 uninstallnodejs.sh
is executed on the command line
When you're done deleting all that stuff, you're done deleting node.
but there are a lot of node-based installed software and command-line tools that need to be reinstalled, such as react-native, supervisor,pm2 etc
need to delete the files under /usr/local/bin, actually they are just soft connections, it's all under /usr/local/lib/node_modules/.
was removed in the previous step, but you can still find it by pressing the TAB key because these soft connections still exist

Error: ENOENT: no such file or directory, open ‘E:\Program Files\nodejs\tmp\upload_38b32f25bc984333c

Look at the picture first:

The main reason for this problem is that the files you are uploading are not in the same folder
So put the folder TMP and the running JS files in the same directory, as shown in the figure below:

Then the path is changed. The first path I wrote was fs.readfile (“/ TMP /test.png”…) There is no problem changing “/ TMP /test.png” to “./ TMP /test.png”
Fs. ReadFile (“./TMP/test. The PNG “, “binary”, function (the error, the file) {
if (error) {
response. WriteHead (500, {” content-type “:” text/plain “});
response. Write (error + “\ n”);
the response. The end ();
} else {
response. WriteHead (200, {” content-type “:” image/PNG} “);
response. Write (file, “binary”);
the response. The end ();


Cannot find module ‘lodash’

The scenarios in which this problem occurs vary, but the solutions are basically the same. This article takes lodash module as an example

    if Cannot find module lodash appears after the pull code is run, usually someone else USES a plug-in lodash, but you do not have it in your local environment, you can directly go to the package. Json to check if there is lodash, if there is, that proves that you do not install the lodash, use CNPM install to install it. Json package.json not found, Cannot find module lodash, global search under the file lodash, if the file is not used, then delete node_module, re-use CNPM install can be installed; Json . Just ask the relevant person to submit it, and then refer to step 1. Json, node_module package-lock. Use NPM cache clean --force to clear the cache. Then use NPM install to install.

Json copy a copy of packing-lock-. jsoncopy a copy of packing-lock. jsoncopy a copy of packing-lock. json copy a copy of packing-lock-. (Of course, if the file is u update status, then don't bother, check the update content, and then submit it)

UnhandledPromiseRejectionWarning Error: Can‘t set headers after they are sent (How to Fix)

(node:57300) UnhandledPromiseRejectionWarning: Error: Can't set headers after they are sent.
    at validateHeader (_http_outgoing.js:491:11)
    at ServerResponse.setHeader (_http_outgoing.js:498:3)

In the Node project, you encountered this error while doing module splitting.
is checked to be package.json deleted

"babel-preset-env": "1.3.2",
"babel-preset-es2015": "6.24.1",
"babel-preset-stage-2": "6.24.1"

These three modules cause these three modules not to be deleted.
is originally required by the server to render the json inside the reference file is relative. Node_modules relative to the root directory, so the items below the root directory are related to modules such as vue, Babel-Polyfill, etc.

Solve the problem of Too many levels of symbolic links

Too many levels of symbolic links when using ln to create soft links

[email protected]:/opt/jdk1.8.0_181/bin# ln-s Java /usr/local/bin/ Java

change to:
root @instancevgiv786y :/opt/jdk1.8.0_181/bin# ln-s /opt/jdk1.8.0_181/bin/ Java /usr/local/bin/ Java
Obviously I’m installing the JDK, but why would I want to create this soft connection?Just add the environment variable at /etc/profile. However, when I connected this server as one of Jenkins’ nodes, I was surprised to find that Java could not be found. Obviously, I added the environment variable and it took effect. Jenkins had to look under various bin directory, so I created this soft connection.

VUEJS Failed to execute ‘removeChild’ on ‘Node’: The node to be removed is not a child of

Failed to execute ‘removeChild’ on ‘Node’ : The Node to be removed is not a child of this Node.

in my previous post
VUEJS project practice 5 Dialog pop-up box MessageBox (very nice bootstrap style)
has introduced a MesageBox style combined with bootstrap style
Then in the previous post
VUEJS project practice 4 custom keyboard instructions (keystrokes to get focus)
introduced a way for keystrokes to automatically get focus and trigger events.
Now when MessageBox binds Enter, an error
messagebox.vue?Cb02 :80 Uncaught DOMException: Failed to execute ‘removeChild’ on ‘Node’ : The Node to be removed is not a child of this Node.

First post the message.vue file

  <div v-key-bind-listen>
      <div class="msgBox" v-show="isShowMessageBox">
        <div class="msgBox_header">
          <div class="msgBox_title">
            <h3>{{ title }}</h3>

        <div class="msgBox_content">
          <p>{{ content }}</p>

        <div class="msgBox_btns">
          <button type="button" class="btn btn-lime btn-lg" id="confirmBtn" @click="confirm"  bind_key="ENTER">确定</button>
          <button type="button" class="btn btn-dark btn-lg" id="cancelBtn" @click="cancel"  bind_key="ESC">取消</button>



  export default {
    name: 'messageBox',
      return {
        title: '',
        content: '',
        isShowMessageBox: false,
        resolve: '',
        reject: '',
        promise: '' // 保存promise对象
    methods: {
        this.model.show = false;
    // 确定,将promise断定为resolve状态
    confirm: function () {
      this.isShowMessageBox = false;
    // 取消,将promise断定为reject状态
    cancel: function () {
      this.isShowMessageBox = false;
    // 弹出messageBox,并创建promise对象
    showMsgBox: function () {
      this.isShowMessageBox = true;
      this.promise = new Promise((resolve, reject) => {
        this.resolve = resolve;
        this.reject = reject;
      // 返回promise对象
      return this.promise;
    remove: function () {
      setTimeout(() => {
      }, 300);
    destroy: function () {

<style scoped>
  .msgBox {
    position: fixed;
    z-index: 4;
    left: 50%;
    top: 35%;
    transform: translateX(-50%);
    width: 420px;
    background-color: black;
    opacity: 0.55;

  .msgBox_header {
    padding: 20px 20px 0;

  .msgBox_title {
    padding-left: 0;
    margin-bottom: 0;
    font-size: 26px;
    font-weight: 800;
    height: 18px;
    color: #fff;

  .msgBox_content {
    padding: 30px 20px;
    color: #fff;
    font-size: 18px;
    font-weight: 200;

  .msgBox_btns {
    padding: 10px 20px 15px;
    text-align: right;
    overflow: hidden;

  @keyframes show-messageBox {
    from {
      opacity: 0;
    to {
      opacity: 1;


  @keyframes bounce-in {
    from {
      opacity: 0;
    to {
      opacity: 1;



The V-key-bind-listen instruction defined here is used for key listening. For details, please refer to the previous blog. It would be boring to write it again.
VUEJS project practice four custom keyboard commands (keys to get focus)
When you press ESC to cancel, there is no problem
when you press ENTER to confirm, the error will appear in the newspaper
messagebox.vue?Cb02:80 Uncaught DOMException: Failed to execute ‘removeChild’ on ‘Node’ : The Node to be removed is not a child of this Node.
Error is located via console.

add a line of logs in the destroy method. The console prints this.$el.


Add a line of logs to determine if this.$el is a child of the body