npm install failing on npm v6 but passing on v8 (latest) - node.js

I am trying to install a package which I created (let's say abc) and getting the below error
Stacktrace:
$ npm i -g abc
/<home>/.nvm/versions/node/v12.22.10/bin/abc -> /<home>/.nvm/versions/node/v12.22.10/lib/node_modules/abc/src/bin/runner.js
npm ERR! code ENOENT
npm ERR! syscall chmod
npm ERR! path /<home>/.nvm/versions/node/v12.22.10/lib/node_modules/abc/bin.js
npm ERR! errno -2
npm ERR! enoent ENOENT: no such file or directory, chmod '/<home>/.nvm/versions/node/v12.22.10/lib/node_modules/abc/bin.js'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent
npm ERR! A complete log of this run can be found in:
npm ERR! /<home>/.npm/_logs/2022-08-05T07_58_00_703Z-debug.log
The issue is happening on npm v6 (I am using 6.14.17) while it is able to install the package with v8 (latest)
The changes I made in the version that I published is have a very basic script and put it in bin.
// package.json snippet
"license": "xyz",
"bin": {
"my-package": "./src/bin/runner.js",
"setup": "./bin.js"
},
"dependencies": {}
// package.json snippet (older version which is getting installed correctly with v6 as well
"license": "xyz",
"bin": {
"my-package": "./src/bin/runner.js"
},
"dependencies": {}
The folder structure is as follows:
-- root-folder
-- src
-- bin
-- runner.js
-- bin.js
-- package.json
Things I tried:
Different versions of node - failing for all with npm v6
Working for same node versions (v12 and above) for npm v8 (latest)
The same code was working on npm v6 with npm link (before publishing while testing)
Tried older versions published of the package and they were installed as expected so something in this release is causing the issue
npm cache clean --force
npm install using --force
npm install with and without -g

Try this command npm i --froce
This should bypass some problems in your dependencies!

Related

What may I be missing while trying to install npm bootstrap to my project?

I am trying to use npm to install bootstrap on my project. I have already
npm init and confirmed package.json is on the associated folder.
However, npm install bootstrap keeps bringing a dependency error
npm ERR! code ENOSELF
npm ERR! Refusing to install package with name "bootstrap" under a package
npm ERR! also called "bootstrap". Did you name your project the same
npm ERR! as the dependency you're installing?
npm ERR!
npm ERR! For more information, see:
npm ERR! https://docs.npmjs.com/cli/install#limitations-of-npms-install-algorithm
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\USER\AppData\Roaming\npm-cache_logs\2021-07-30T11_18_57_954Z-debug.log
How do I fix this error pls?
You are probably named your package as a bootstrap, which prevents npm from installing the package with the same name from the registry.
Try to rename your package to bootstrap-test in your package.json:
{
"name": "bootstrap-test",
"version": "0.1.0",
"description": "My first bootstrap project!"
}

Getting npm ERR! ENOTDIR: not a directory while installing package which depends on another

Note: I have latest npm and node versions. I have tried the answers provided in npm install error ENOTDIR but didn't work for me.
I need to install 2 npm modules got as .tgz packages on NodeRed
1. x.tgz
2. y.tgz
I could install the first package using npm install path/to/x.tgz
I used the same command npm install path/to/y.tgz command but I am getting following error.
malintha#malintha-VirtualBox:~/.node-red$ sudo npm install path/to/y.tgz
npm ERR! path path/to/y.tgz/x.tgz
npm ERR! code ENOTDIR
npm ERR! errno -20
npm ERR! syscall stat
npm ERR! ENOTDIR: not a directory, stat 'path/to/y.tgz/x.tgz'
According to the error log, y module is looking for x.tgz inside it. Then I checked the package.json of y.tgz artefact.
I can see it has x.tgz as the dependency inside it, but it don't have x.tgz inside it.
"dependencies": {
"#abc/pqr": "file:x.tgz",
"ajv": "^6.5.1",
"debug": "^3.1.0"
}
According to the instructions, it should be fine if I install the x.tgz and then y.tgz. I could install these x and y some time back but now I cannot install it.
What might be the root cause for this issue?
Is this npm and node versions related issue?
I'm re-writing this answer after deleting my old answer. I tested it with and node v11.6.0 and npm v4.5.0-next.0 on Linux.
To install y.tgz, I tried as below:
I copied both tgz files in the same directory.
I modified package.json of y.tgz as below:
"dependencies": {
"#abc/pqr": "file:../x.tgz",
"ajv": "^6.5.1",
"debug": "^3.1.0"
}
dependencies supports file: + relative path or absolute path.
So, you can choose anyone as your development condition.

npm i Running command - failed! (exit code 254)

Ionic :3.20.0
node: v8.10.0
npm: 5.6.0
npm i
✖ Running command - failed!
[ERROR] An error occurred while running npm i (exit code 254):
npm ERR! path
/Users/lucaszimmermann/Desktop/myApp/node_modules/tsickle/src/main.js
npm ERR! code ENOENT
npm ERR! errno -2
npm ERR! syscall chmod
npm ERR! enoent ENOENT: no such file or directory, chmod
'/Users/lucaszimmermann/Desktop/myApp/node_modules/tsickle/src/main.js'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent
npm ERR! A complete log of this run can be found in:
npm ERR!
/Users/lucaszimmermann/.npm/_logs/2018-04-04T16_41_39_270Z-debug.log
I faced a similar issue after doing the below actions this issue solved.
Delete package-lock.json file.
Open cmd/terminal in administrator mode.
run command: npm install
run command: npm update
Node version is likely incompatible. There'd be an expected version actual version. Use nvm or similar to install and change node versions.
Delete node_modules and try install again. You probably get a message similar to:
error ts-jest#26.1.2: The engine "node" is incompatible with this module. Expected version ">= 10.21.0". Got "10.20.1"
error Found incompatible module.
You wan't try to install npm packages.
You have two options to install some packages:
First Option:
npm install <package>
npm i <package>
Second Option:
If you wan't to create an automated installation process without each package, you must provide an packge.json - Here are all depencies listed. You can only run npm i or npm install without an package name, if you have an package.json
A full documentation about that is on NPM: https://docs.npmjs.com/files/package.json

How to unlink a npm command-line tool?

I use node to write a command-line tool.
this is the index.js.
#!/usr/bin/env node
console.log('qiuyuntao');
this is the package.json
{
"name": "qiu",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"bin": {
"qyt": "index.js"
}
}
After I use command npm link, I can use command qyt anywhere. Now I want to unlink the command, I use npm unlink, it said
npm ERR! gentlyRm containing path /usr/local/lib/node_modules/qiu isn't under npm's control
npm WARN install:qiu#1.0.0 Refusing to delete: /usr/local/bin/qyt not in /usr/local/lib/node_modules/qiu
- qiu#1.0.0 node_modules/qiu
So, what should I do to unlink it?
Without knowing what version of npm you are using and if this is a bug thats being resolved I suspect that your global prefix is misconfigured perhaps.
At any rate the easiest solution is to manually remove the symlinks /usr/local/bin/qyt and /usr/local/lib/node_modules/qiu. If you are using the latest version of npm look into filing an issue, otherwise update (npm i -g npm).
Updating npm 3.9.5 > 4.0.5 fixed the same issue for me
Before update:
$ npm unlink
npm WARN install:#coolman/my-module#1.0.0 Refusing to delete /Users/coolman/.nvm/versions/node/v6.2.0/bin/mymod: ../lib/node_modules/my-module/index-cli.js symlink target is not controlled by npm /Users/coolman/.nvm/versions/node/v6.2.0/lib/node_modules/#coolman/my-module
- #coolman/my-module#1.0.0 node_modules/#coolman/my-module
$ npm --version
3.9.5
After update:
$ sudo npm install npm#latest -g
$ npm --version
4.0.5
$ npm unlink
- #coolman/my-module#1.0.0 node_modules/#coolman/my-module
And to repeat npm link, I needed to manually remove the bin:
$ npm link
npm WARN #my-company/my-module#1.0.0 No repository field.
npm ERR! Darwin 16.1.0
npm ERR! argv "/Users/coolman/.nvm/versions/node/v6.2.0/bin/node" "/Users/coolman/.nvm/versions/node/v6.2.0/bin/npm" "link"
npm ERR! node v6.2.0
npm ERR! npm v4.0.5
npm ERR! path /Users/coolman/.nvm/versions/node/v6.2.0/bin/mymod
npm ERR! code EEXIST
npm ERR! Refusing to delete /Users/coolman/.nvm/versions/node/v6.2.0/bin/mymod: ../lib/node_modules/my-module/index-cli.js symlink target is not controlled by npm /Users/coolman/my-company/tools/my-module
npm ERR! File exists: /Users/coolman/.nvm/versions/node/v6.2.0/bin/mymod
npm ERR! Move it away, and try again.
npm ERR! Please include the following file with any support request:
npm ERR! /Users/coolman/my-company/tools/my-module/npm-debug.log
$ rm /Users/coolman/.nvm/versions/node/v6.2.0/bin/mymod
$ npm link
npm WARN #coolman/my-module#1.0.0 No repository field.
/Users/coolman/.nvm/versions/node/v6.2.0/bin/mymod -> /Users/coolman/.nvm/versions/node/v6.2.0/lib/node_modules/#coolman/my-module/index-cli.js
/Users/coolman/.nvm/versions/node/v6.2.0/lib/node_modules/#coolman/my-module -> /Users/coolman/perkbox/tools/run-with-pb-session

NPM Update failing for private repo

I have an express project that accesses some common node code that I keep in a private repository in github. I have a line like the following in my package.json file
git+ssh://git#github.com:MYGITHUBACCT/MYPROJECT.git#master
When I run npm install, everything works correctly and it pulls my common code from the private repo and places it in my node_modules directory. However, when I run npm update, it fails on my private repo and displays the following:
npm ERR! 404 'MYPROJECT' is not in the npm registry.
npm ERR! 404 You should bug the author to publish it
npm ERR! 404
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, or http url, or git url.
npm ERR! System Darwin 12.2.0
npm ERR! command "node" "/usr/local/bin/npm" "update"
npm ERR! cwd /Users/ginnyd/dev/gg-web
npm ERR! node -v v0.8.16
npm ERR! npm -v 1.1.69
npm ERR! code E404
Is there anything special I need to do in the package.json so that I can run the update and have it pull from GitHub?
Thanks
Ginny
Apparently, this is still an open issue with npm.
Meanwhile, to update git dependencies, you have to remove them first and then doing an npm install.
rm -rf node_modules/MYPROJECT
npm install
This have fixed in npm, please upgrade to npm >= 1.3.10
Sample usage
"dependencies": {
"thing": "git://github.com/myGitHubRepo/repo.js.git#56477cb",
}
Some day later
"dependencies": {
"thing": "git://github.com/myGitHubRepo/repo.js.git#67f90b5",
}
Then npm install again and you will get new ref!
If your "myGitHubRepo/repo.js" is a private package you should set "private": true there to ensure it doesn't get accidentally published to npm registry

Resources