Tag Archives: node.js

NPM run dev error: cannot find module ‘webpack cli / bin / config yargs‘

1- Open your package.json file

"devDependencies": {
    "webpack": "^5.2.0",
    "webpack-cli": "^4.1.0",
    "webpack-dev-server": "^3.11.0"
}

Webpack-cli: “^4.1.0”, which is version 4.*
2- Uninstall the current webpack-cli directive: NPM uninstall webpack-cli
3.* version directive: NPM install [email protected] -d

Just run NPM run dev!
 

When NPM install, make: G + +: command not found will be prompted

When NPM install is installed, an error may appear that prompts make:g++ Command not found, as follows:
node-pre-gyp WARN Using request for node-pre-gyp https download
node-pre-gyp WARN Tried to download(404): https://github.com/yanyiwu/nodejieba/releases/download/2.4.1/nodejieba-v2.4.1-node-v72-linux-x64.tar.gz
node – pre – gyp WARN the pre – built binaries not found for [email protected] and [email protected] (node-v72 ABI, glibc) (falling back to source compile with node-gyp)
make: Entering directory /home/smart/jenkins/workspace/microservice_vue_demo/node_modules/nodejieba/build' CXX(target) Release/obj.target/nodejieba/lib/index.o make: g++: Command not found make: * * * [Release/obj. Target/nodejieba/lib/index o] make the Error 127: brigade directory /home/smart/Jenkins/workspace/microservice_vue_demo/node_modules/nodejieba/build '
gyp ERR! build error
gyp ERR! stack Error: make failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (/usr/local/nodejs/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:194:23)
gyp ERR! stack at ChildProcess.emit (events.js:310:20)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:275:12)
gyp ERR! System Linux 3.10.0-957.21.3. El7.x86_64 The command "/ usr/local/nodejs/bin/node" "/ usr/local/nodejs/lib/node_modules/NPM/node_modules/node - gyp/bin/node - gyp. Js" "build" fallback "- - to - build" "- the module =/home/smart/Jenkins/workspace/microservice_vue_demo/node_modules/nodejieba/build/Release/nodejieba node" "- module_name = nodejieba" "- module_path =/home/smart/Jenkins/workspace/microservice_vue_demo/node_modules/nodejieba/build/Release" "- napi_version = 5" "- node_abi_napi = for a" "- napi_build_version = 0" "- node_napi_label = node - v72"
gyp ERR! cwd /home/smart/jenkins/workspace/microservice_vue_demo/node_modules/nodejieba
gyp ERR! Node-v v12.16.3 Node-gyp-v v5.1.0
gyp ERR! not ok
node-pre-gyp ERR! build error
node-pre-gyp ERR! stack Error: Failed to execute '/ usr/local/nodejs/bin/node/usr/local/nodejs/lib/node_modules/NPM/node_modules/node - gyp/bin/node - gyp. Js build - fallback - to - build --module=/home/smart/jenkins/workspace/microservice_vue_demo/node_modules/nodejieba/build/Release/nodejieba.node --module_name=nodejieba - module_path =/home/smart/Jenkins/workspace/microservice_vue_demo/node_modules/nodejieba/build/Release - napi_version = 5 - node_abi_napi = for a - napi_build_version = 0 - node_napi_label = node - v72 (1)
' node-pre-gyp ERR! stack at ChildProcess. (/home/smart/jenkins/workspace/microservice_vue_demo/node_modules/node-pre-gyp/lib/util/compile.js:83:29)
node-pre-gyp ERR! stack at ChildProcess.emit (events.js:310:20)
node-pre-gyp ERR! stack at maybeClose (internal/child_process.js:1021:16)

install g++, switch to root, and execute

[email protected]:~# yum install gcc -c++

After waiting for the package installation to complete, execute g++ -v to see that g++ has been successfully installed

[email protected]:~# g++ -v
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/4.8.5/lto-wrapper
Target: x86_64-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-bootstrap --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-linker-hash-style=gnu --enable-languages=c,c++,objc,obj-c++,java,fortran,ada,go,lto --enable-plugin --enable-initfini-array --disable-libgcj --with-isl=/builddir/build/BUILD/gcc-4.8.5-20150702/obj-x86_64-redhat-linux/isl-install --with-cloog=/builddir/build/BUILD/gcc-4.8.5-20150702/obj-x86_64-redhat-linux/cloog-install --enable-gnu-indirect-function --with-tune=generic --with-arch_32=x86-64 --build=x86_64-redhat-linux
Thread model: posix
gcc version 4.8.5 20150623 (Red Hat 4.8.5-39) (GCC) 

Re-run NPM Install.

node.js Error: write epipe problem solved!

1. Open the Gulpfile.js file in the installation directory
2, as shown in the figure below, the error place annotation or default in the operation will be deleted accordingly. If you need to use the annotation, please download the lower version and try to install the slave again


3. Error report is shown in the figure below

Nodejs exception error: listen eacces 127.0.0.1:8000

This article is reprinted, if you do not want to infringe copyright, please timely inform
The original address to http://blog.csdn.net/y2010081134/article/details/72800812
Exception information

Error: listen EACCES 127.0.0.1:8000
    at Object.exports._errnoException (util.js:1018:11)
    at exports._exceptionWithHostPort (util.js:1041:20)
    at Server._listen2 (net.js:1245:19)
    at listen (net.js:1294:10)
    at net.js:1404:9
    at GetAddrInfoReqWrap.asyncCallback [as callback] (dns.js:62:16)
    at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:81:10)

npm ERR! Windows_NT 10.0.14393
npm ERR! argv "D:\\nodejs\\node.exe" "D:\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "start"
npm ERR! node v6.10.3
npm ERR! npm  v3.10.10
npm ERR! code ELIFECYCLE
npm ERR! [email protected] start: `http-server ./app -a localhost -p 8000 -c-1`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] start script 'http-server ./app -a localhost -p 8000 -c-1'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the angular-phonecat package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     http-server ./app -a localhost -p 8000 -c-1
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs angular-phonecat
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls angular-phonecat
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     E:\Git\Repository\angular-phonecat\npm-debug.log

The solution


The exception is caused by 8000 port being occupied. Check the 8000 port being occupied under Windows

E:\Git\Repository\angular-phonecat>netstat -ano|findstr "8000"
  TCP    0.0.0.0:8000           0.0.0.0:0              LISTENING       18480
  TCP    127.0.0.1:8000         127.0.0.1:50236        TIME_WAIT       0
  TCP    127.0.0.1:8000         127.0.0.1:50237        TIME_WAIT       0
  TCP    127.0.0.1:8000         127.0.0.1:50238        TIME_WAIT       0
  TCP    127.0.0.1:8000         127.0.0.1:50239        TIME_WAIT       0
  TCP    127.0.0.1:8000         127.0.0.1:50240        TIME_WAIT       0
  TCP    127.0.0.1:8000         127.0.0.1:50286        TIME_WAIT       0
  TCP    127.0.0.1:50285        127.0.0.1:8000         TIME_WAIT       0
  UDP    0.0.0.0:8000           *:*                                    18480

Because process 0 is a system process, executing “Taskkill/PID 0” will not kill it. So, find another way to change the port, as follows:

Under node’s installation root, find package.json, search 8000, and replace with 8888


 

Then execute the command NPM Start from the command line, and it starts successfully

Enter it in the browser
http://localhost:8888
, you can see the successful access

On and off of timer in JS

setInterval()
When a function
is called for a specified period of time:

setInterval(function,time,lang)

function: function to be called or code string to be executed
time: required parameters, every how long to call the function, in milliseconds
lang: optional parameters, running JScript | VBScript | JavaScript
clearInterval()
Means to stop the setInterval timer call function

function getTime() {
        console.log(123);
        if (true) {
            clearInterval(db)
        }
    }

let db = setInterval(getTime, 1000)

setTimeout()
Call a function after a certain time
syntax:

setTimeout(function,time,lang)

Function:
function: required, to be called
time: required, number of milliseconds to wait before executing code
lang: optional, script language: JScript | VBScript | JavaScript

Error: Cannot find module ‘express’

Problem description:
System: Windows 7 x64
Node.js version: Version is: V4.2.4 LTS
Introduction to Node.js: Notes on setting up the Node.js Web development environment under Windows 7
Sample code downloaded from IBM Bluemix. Error starting debugging locally: Error: Cannot find Module ‘Express’
The diagram below:

Solutions:
Just execute the command “NPM install” in the corresponding application directory, as shown in the figure below:

Before the above operation, the command “NPM install -g Express” was also executed, I wonder if it has any effect, as shown in the figure below:

= = = = = = = = = = = = = = = = = = = = = = = = = = = = I am separated line = = = = = = = = = = = = = = = = = = = = =
Please use a word to show that although you spend Valentine’s Day alone, but not lonely……
A: Where is my pump?
B: Watching ghost movies at night, I instantly feel someone in the kitchen, the toilet, the wardrobe, and under the bed. I don’t feel bored at all…
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
Valentine’s Day is the day when the mistress and the principal room rob a man, the day when the underground party rises to the surface, the day when the rose appreciates, and the day when the living are created! At 4 p.m., the florist smiled; At six o ‘clock in the evening, the owner of the restaurant smiled; At 9 p.m., the nightclub manager smiled; Midnight, the hotel owner smiled; The next day, the drugstore owner smiled; A month later, the gynecological hospital doctors and nurses all smiled.