Tag Archives: Npm

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

root@linx:~# yum install gcc -c++

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

root@linx:~# 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.

On NPM audit fix

Background:
The following reminder appears when NPM Install is executed

added 253 packages from 162 contributors and audited 1117 packages in 42.157s
found 5 vulnerabilities (1 low, 4 high)
  run `npm audit fix` to fix them, or `npm audit` for details html

According to the command prompted by the console, type ‘NPM Audit Fix’ and the console prompts:

1 package update for 5 vulns involved breaking changes
  (use `npm audit fix --force` to install breaking changes; or do it by hand)

After typing: ‘NPM Audit Fix — Force’, the console prompts:

added 199 packages from 111 contributors, removed 64 packages and updated 23 packages in 42.194sfixed 5 of 5 vulnerabilities in 1117 scanned packages
  1 package update for 5 vulns involved breaking changes
  (installed due to `--force` option)

Re-enter ‘NPM Audit’ :

                      === npm audit security report ===

found 0 vulnerabilities
 in 4598 scanned packages

At last everything was all right.
Out of curiosity, I read the introduction of NPM Audit Fix on the official website of NPM.
NPM audit: [email protected]& amp; NPm@6, which allows developers to analyze complex code and identify specific vulnerabilities and defects.
NPM Audit Fix: [email protected] detects vulnerabilities in project dependencies and automatically installs those that need to be updated without having to track and fix them themselves.
In the meantime, the website also provides some other commands, which are summarized as follows:
1. Run audit Fix, but only update PKglock, not Node_modules:

$ npm audit fix --package-lock-only

2. Update only the packages installed in Dependencies, and skip the packages in devDependencies:

$ npm audit fix --only=prod

3. Run the command to get the contents of the audit Fix to be updated and output the installation information in JSON format, but the update is not actually installed:

$ npm audit fix --dry-run --json

4. Get the detailed test report in JSON format

$ npm audit --json

The attached:
NPM – audit website address: https://docs.npmjs.com/cli/audit

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

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

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

On the use of NPM cache clean — force

Today, I removed node_modules and re-tried NPM Run Install with the following error:

npm ERR! Unexpected end of JSON input while parsing near '...l.com"}],"directories'

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/louyanping/.npm/_logs/2018-12-14T03_32_00_994Z-debug.log
louyanpingdeMacBook-Pro:cnpc_group_buying louyanping$

Remember that this error has occurred before, and then I do a search, and find the solution, which is to execute NPM cache clean --force (if this still doesn't work for some people, just delete package-lock.json and try again).
So the question is, why does this happen?
Take a look at how NPM Install works:

    issue the NPM install command NPM downloads the compressed package from the registry’s url, and store it in ~/. NPM (local NPM cache path) directory to unzip the compressed package to the node_modules directory

of the current project
In fact, when a module is installed, two copies are saved locally. One is the compressed package in ~/.npm and the other is the unzipped code in node_modules. However, when you run NPM install, it only checks the node_modules directory, not the ~/.npm directory. If a module has a zip package under ~./ NPM but not installed in the node_modules directory, NPM will still download a new zip package from the remote repository.
The cache mechanism that we want to implement offline module installation using modules that have been previously backed up in the cache has been overwritten in V5. The cache will be maintained globally by NPM and the developer will no longer have to worry about it. The offline installation will no longer attempt to connect to the network, but the degraded attempt to read from the cache or fail. If you offline, NPM will use your cache seamlessly.
But, in fact, After watching all this, I still feel overwhelmed… Still checked some information, but can only find that:
this is a problem with the NPM cache corruption. Although they have self-repaired in newer versions of NPM, which is usually guaranteed to be corruption-free, it doesn’t seem to work that well.

, where a Forcing clean cache could solve a similar problem.
An error occurred while parsing one of the JSON-formatted cache files. Cache found in ~/.npm/_cacache (in Linux) and %AppData%/ nPm-Cache (in Windows). PS: For my current NPM release, when I check, there are 3 directories.
If you continue to view the first or second file, the structure looks like this:

Each cache file has a json format

This led to speculation that the files might have gone wrong when the cache was re-installed, a so-called cache corruption problem. (Welcome to correct, according to the data really can not find the exact specific reason!)

Error: ENOENT: no such file or directory, mkdir E:\

The next time you install the VUE, you have a problem. I think it’s helpful for you to write it down.
Process: go to nodejs official website to download and press vue. After installation,
appears the following problems:


baidu learned that it may be the network problem when downloading and installing
solution 1: hang.

solution 2:
: try the following command
NPM rebuild node-sass
npm install npm -g
sudo npm install -g npm
npm install -g npm
npm cache clear
npm cache verify
Npm install -g bower
each command is from a different article, you can type a command npm-v to try npm-v, then type another command and try npm-v again.
result: one is not make, every command popup window again to find E disk
solution 3: some say not delete registry clean, first remove node, and then use RegClean Pro delete registry, and then come back, that person is then solved the
result: try, can’t solve the problem 4:
scheme may be the problem of environment variable
result: baidu NPM environment variables related question, again after the manual configuration can solution to
5: Node_js \node_global
prefix=D:\ node_global
cache=D:\ node_global
cache=D:\ node_cache
. Download and install a year ago, two years ago, three years ago, is no 7:
program may be C: \ Users \ Administrator of the directory. The configuration in the NPMRC problems
the result: . NPMRC file into the
the prefix = D: \ node. Js \ node_global
cache = D: \ node. Js \ node_cache
registry=http://registry.cnpmjs.org/
python = python2.7
msvs_version = 2015
results: problem solving
To sum up, the above schemes are suitable for different people, and each scheme has been solved after someone USES it. I will record it here, so that those who are destined to install VUE in the future can take fewer detours.
attach my connection on stackoverflow for help
https://stackoverflow.com/questions/62149314/npm-v-error-enoent-no-such-file-or-directory-mkdir-e-6-14-4/62171359#62171359

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)

Gulp error report, assertionerror [err_ ASSERTION]: Task function must be specified

Async must be added before the callback function of task task to form an asynchronous function. For example:

gulp.task('cssmin', async() => {
    gulp.src(['./src/css/*.less', './src/css/*.css'])
        .pipe(less())
        .pipe(csso())
        .pipe(gulp.dest('./dist/css'));
});

There are also hints in the error message:
The following tasks did not complete: default, < anonymous>
Did you forget to signal async completion?
 
Build the global task call to report an error, such as:
PS C:\Users\J\Desktop\demo\gulp-demo> Gulp assert. Js: 385
throw err;
^
AssertionError [ERR_ASSERTION]: Task function must be specified
at gulp. set [as _setTask] (C: Users\J\node_modules\ lib\set-task.js:10:3)
at gulp. Task (C: \ Users \ \ J node_modules \ undertaker \ lib \ task js: 8)
the at Object. & lt; anonymous> (C: \ Users \ \ Desktop \ demo \ J gulp – demo \ gulpfile js: 60:6)
at the Module. The _compile (internal/modules/CJS/loader. Js: 1176:30)
at the Object. The Module. _extensions.. Js (internal/modules/CJS/loader. Js: 1196:10)
at the Module. The load (internal/modules/CJS/loader. Js: 1040:32)
at the Function, the Module. _load (internal/modules/CJS/loader. Js: 929:14)
the at The Module. The require (internal/modules/CJS/loader. Js: 1080:19)
at the require (internal/modules/CJS/helpers. Js: 72:18)
at the execute (C:\Users\J\AppData\ NPM \node_modules\gulp-cli\lib\versioned\^4.0.0\index.js:36:18) {
generatedMessage: false,
code: ‘ERR_ASSERTION’,
actual: false,
expected: True,
operator: ‘= =’
}
 
Simply prefix the function name of the call with Gulp.Series

gulp.task('default', gulp.series(['htmlmin', 'cssmin', 'jsmin', 'copy', async(done) => done]))

 

Webpack 4 : ERROR in Entry module not found: Error: Can’t resolve ‘./src’

ERROR in Entry Module not found: ERROR: Can’t resolve ‘./ SRC ‘in’ E:\ Documents\VSCode files\WebPackProject ‘
Specify the inlet and outlet through the configuration file
Js
(must be in the project root directory)

const path = require('path');

module.exports = {
  entry: './src/index.js',
  output: {
      path: path.resolve(__dirname, 'dist'),
    filename: 'bundle.js'
  }
};

Not packaged by configuration file
By default, Webpack4 does not need to create webpack.config.js to configure the packaged entry and exit.
By default,
The entry is ./ SRC /index.js file
Exit to ./dist/main.js file
Directory structure:

Js is in the correct position. Run the command in the project root directory:

webpack

You are ready to pack.


So now you can see that under the project directory, dist folder, you’ll see the packaged file main.js;
In the HTML file index. HTML which needs to be introduced, it can be correctly introduced.

You can also specify it manually using the following command:
webpack./SRC /index.js -- output-filename. /dist/main.js --output-path. --mode development
or
webpack ./src/index.js -o ./dist/main.js --mode development
note:
, --mode development is the specified development mode, without which warning will be reported;
Another mode is --mode production specifies the production mode. In this mode, the packaged js file will be compressed, but the former will not.
Webpack will prompt a warning when executing directly from above. Closing the warning can be packaged by the following command:
webpack --mode development
or
webpack --mode production
`


NPM- Cannot find module ‘xxxxx’

Error: Cannot find module 'semver'
    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 Object.<anonymous> (/usr/local/lib/node_modules/npm/lib/utils/unsupported.js:2:14)
    at Module._compile (module.js:660:30)
    at Object.Module._extensions..js (module.js:671:10)
    at Module.load (module.js:573:32)
    at tryModuleLoad (module.js:513:12)
    at Function.Module._load (module.js:505:3)

Cannot find module ‘XXXXX’ has encountered this problem,
I have tried:

npm install semver 
npm install -g socket.io

This is not going to work.
and then find another solution.
first see if your NPM is useful. Check method: open the terminal and enter

npm -v

If the error is reported, then it is necessary to re-install NPM. First, the original NPM is deleted. The method is:
, you can go to the global NPM package to have a look, the path is:

/usr/local/lib/node_modules/npm

Go to the Semver folder in NOde_modules in NPM and you’ll see that it’s empty! Or no, we will know why semver module can not be found!
1. First delete the global NPM package: just mentioned /usr/local/lib/node_modules/ NPM, this NPM folder delete
2. Go to /usr/local/lib/node_modules and clone git from GitHub

git clone --recursive git://github.com/isaacs/npm.git

This brings the new NPM package back to global node_modules
.

npm -v

Check it in the terminal. If you can print it out, that’s fine.

Unloading and installation of node and NPM of Vue Foundation

Problem background: Node and NPM have been installed on the original MAC computer, but in the process of a misoperation, it was found that the nPM-V command could not be typed out, prompting the Command not Found. Tamping many times, finally decisive after all kinds of search uninstall clean and then reinstall all.

Problems:
1 node-v can have a version prompt, npm-v does not have a version prompt, and the output NPM command not found
2 brew install node can have a version prompt, brew install NPM prompt error.
Solutions:
(1) Delete old files: delete them according to the prompts, or delete them directly (operation can be carried out in access)

sudo npm uninstall npm -g
sudo rm -rf /usr/local/lib/node /usr/local/lib/node_modules /var/db/receipts/org.nodejs.*
sudo rm -rf /usr/local/include/node /Users/$USER/.npm
sudo rm /usr/local/bin/node
sudo rm /usr/local/share/man/man1/node.1
sudo rm /usr/local/lib/dtrace/node.d

Confirm whether to uninstall:

node -v 
npm -v

(2) Reinstall Node

brew install  node

(3) Associate node with the soft link

brew link node

At this time, we may have the following results:

Linking /usr/local/Cellar/node/11.2.0...
Error: Could not symlink include/node/common.gypi
Target /usr/local/include/node/common.gypi
already exists. You may want to remove it:
  rm '/usr/local/include/node/common.gypi'

To force the link and overwrite all conflicting files:
  brew link --overwrite node

To list all files that would be deleted:
  brew link --overwrite --dry-run node
localhost:wkdir meng$ brew link --overwrite node
Linking /usr/local/Cellar/node/11.2.0...
Error: Could not symlink include/node/common.gypi
/usr/local/include/node is not writable.

(4) Then we will enforce it according to the prompts:

brew link --overwrite --dry-run node

Enforcement may require us to delete some of the previous files related to Node, as shown below

Would remove:
/usr/local/include/node/common.gypi
/usr/local/include/node/config.gypi
/usr/local/include/node/libplatform/libplatform-export.h
/usr/local/include/node/libplatform/libplatform.h
/usr/local/include/node/libplatform/v8-tracing.h

(5) Continue to delete the above file and run it again

brew link --overwrite node

Install the NPM

sudo npm install --registry=https://registry.npm.taobao.org

Check node and NPM again

node -v
npm -v

Results:

Note: There may be a variety of problems. When there is a problem, try baidu, and then go on to solve the next problem.
For more personal tutorials, please visit the personal homepage:
Github builds personal blog (2019 update, pro test)
.https://blog.csdn.net/xudailong_blog/article/details/78762262
The public no. :

NPM install Error: EPERM: operation not permitted, mkdir solution

The errors are as follows:

reason: no permissions (no operation allowed)
Solutions:
When opening CMD, run as administrator. In the folder “C:\Windows\system32” (or when opening CMD in the start menu bar), find cmd.exe, right click and select “run as administrator”

.
Win10 How to change C:\Users\ Users\ MySQL 1000 line learning notes, worth collection!