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
Related
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!
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!"
}
I can't install any npm packages. I type in npm install lodash and I get:
npm WARN webdev#1.0.0 No description
npm WARN webdev#1.0.0 No repository field.
npm ERR! path C:\Users\Blake\Desktop\webdev\node_modules\lodash
npm ERR! code ENOENT
npm ERR! errno -4058
npm ERR! syscall rename
npm ERR! enoent ENOENT: no such file or directory, rename 'C:\Users\Blake\Desktop\webdev\node_modules\lodash' -> 'C:\Users\Blake\Desktop\webdev\node_modules\.lodash.DELETE'
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! C:\Users\Blake\AppData\Roaming\npm-cache\_logs\2018-03-15T21_28_45_978Z-debug.log
My package.json file looks like:
{
"name": "webdev",
"version": "1.0.0",
"description": "",
"main": "index.js",
"dependencies": {},
"devDependencies": {},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC"
}
I'm not sure what is wrong. I've tried uninstalling and reinstalling node.js. My npm version is 5.6.0. This happens with every package I've tried to install. Please help, I've been trying to fix this for hours to no avail.
EDIT: I fixed it! The absolute nightmare of a program, MalwareBytes Antimalware was blocking it. I quit out of MalwareBytes and now it is working. Not the first time that program has messed up my coding.
Delete package.json and package-lock.json file, use npm init and try again.
Probably directory node_modules doesnt exist in your project working directory
I would make sure you have npm installed locally in your working directory by running npm init. I would also try re-installing npm.
EDIT:
Remove MalwareBytes Anti-Malware.
I installed jasmine npm module as global. Later on, with the purpose of sharing code and make easy for the team to have all dependencies, I installed jasmine locally to the project using --save-dev.
Issue is that it tries to exec from node_modules global one instead of local one.
Package.json
{
"name": "tdd",
"version": "1.0.0",
"description": "testing tdd practices",
"main": "index.js",
"scripts": {
"test": "$(npm bin)/jasmine"
},
"keywords": [
"test",
"tdd",
"jasmine",
"node"
],
"license": "ISC",
"devDependencies": {
"jasmine": "^2.4.1"
}
}
If my tests are passing I get no errors. In case a test does not pass, I get an error pointing to the global node_modules.
Albertos-MBP:TDD albertof$ npm run test
> tdd#1.0.0 test /Users/albertof/Projects/Web/TDD
> jasmine
Started
......FF
Failures:
1) Html Replacement Regex: should replace . in src attributes for <img src="./hello.jpg">
Message:
Expected '<img static/hello.jpg">' to be '<img src="static/hello.jpg">'.
Stack:
Error: Expected '<img static/hello.jpg">' to be '<img src="static/hello.jpg">'.
at Object.<anonymous> (/Users/albertof/Projects/Web/TDD/spec/htmlSpec.js:22:62)
8 specs, 1 failures
Finished in 0.015 seconds
npm ERR! Darwin 15.5.0
npm ERR! argv "/usr/local/bin/node" "/Users/albertof/npm-global/bin/npm" "run" "test"
npm ERR! node v6.0.0
npm ERR! npm v3.8.8
npm ERR! code ELIFECYCLE
npm ERR! tdd#1.0.0 test: `jasmine`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the tdd#1.0.0 test script 'jasmine'.
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 tdd package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! jasmine
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs tdd
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls tdd
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /Users/albertof/Projects/Web/TDD/npm-debug.log
What is the reason to try to execute from the global node_modules installed?
Running npm bin return the local one for the current project /Users/albertof/Projects/Web/TDD/node_modules/.bin
edit your package.json
"scripts": {
"test": "$(npm bin)/jasmine; exit 0"
}
I am new in the NodeJS world. I have created an loopback(strongloop) webapp, but after it I try to run the npm install command in the application's folder I get this output in the terminal (Ubuntu server 14.04 withd newest updates - in a vagrant instance)
vagrant#vagrant-ubuntu-trusty-64:/vagrant/example-app$ npm install
npm WARN package.json example-app#1.0.0 No license field.
npm WARN optional dep failed, continuing ycssmin#1.0.1
npm WARN deprecated jsonstream#1.0.3: use JSONStream instead
npm WARN optional dep failed, continuing request#2.62.0
npm WARN optional dep failed, continuing loopback-explorer#1.8.0
npm ERR! Linux 3.13.0-62-generic
npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "install"
npm ERR! node v4.1.0
npm ERR! npm v2.14.3
npm ERR! path ../node-uuid/bin/uuid
npm ERR! code EPROTO
npm ERR! errno -71
npm ERR! syscall symlink
npm ERR! EPROTO: protocol error, symlink '../node-uuid/bin/uuid' -> '/vagrant/example-app/node_modules/loopback-datasource-juggler/node_modules/.bin/uuid'
npm ERR!
npm ERR! If you need help, you may report this error at:
npm ERR! <https://github.com/npm/npm/issues>
npm ERR! Linux 3.13.0-62-generic
npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "install"
npm ERR! node v4.1.0
npm ERR! npm v2.14.3
npm ERR! path npm-debug.log.2d5bb41273f18b2da30958b9aa61bfe6
npm ERR! code ETXTBSY
npm ERR! errno -26
npm ERR! syscall rename
npm ERR! ETXTBSY: text file is busy, rename 'npm-debug.log.2d5bb41273f18b2da30958b9aa61bfe6' -> 'npm-debug.log'
npm ERR!
npm ERR! If you need help, you may report this error at:
npm ERR! <https://github.com/npm/npm/issues>
npm ERR! Please include the following file with any support request:
npm ERR! /vagrant/example-app/npm-debug.log
This is the generated package.json which has been generated by loopback framework:
{
"name": "example-app",
"version": "1.0.0",
"main": "server/server.js",
"scripts": {
"pretest": "jshint ."
},
"dependencies": {
"compression": "^1.0.3",
"cors": "^2.5.2",
"loopback": "^2.22.0",
"loopback-boot": "^2.6.5",
"loopback-datasource-juggler": "^2.39.0",
"serve-favicon": "^2.0.1"
},
"optionalDependencies": {
"loopback-explorer": "^1.1.0"
},
"devDependencies": {
"jshint": "^2.5.6"
},
"repository": {
"type": "",
"url": ""
},
"description": "example-app"
}
I have tried to run with sudo npm install but I have gotten exactly the same result.
Versions:
Node v4.1.0
Npm v2.14.3
Vagrant 1.7.4
Ubuntu Server 14.04.3 (with the newest updates)
Here is the npm-log file, it's very long.
If you know my mistake, do not hesitate, just answer :)
This is a problem with Vagrant/VirtualBox. Unfortunately, the synced/shared filesystem doesn't support symlinks.
If you don't require this functionality, the easiest thing to do is to just disable it in your Vagrantfile:
# ...
config.vm.synced_folder ".", "/vagrant", disabled: true
# ...
If you do require it, you may be able to find a work around now that you know it is a problem with symlink support, which npm uses for creating bins :-)
See https://docs.vagrantup.com/v2/synced-folders/basic_usage.html for more details.
The error happens, because your mounted shared directory (/vagrant) is on file system which doesn't support symbolic links.
To void this, you need to tell npm that your file system doesn't support symbolic links, e.g.
npm config set bin-links false
Source: npm doesn't work in vagrant at GH-7308
or by specifying --no-bin-links argument for npm install which will prevent npm from creating symlinks for any binaries the package might contain.
Alternative way is to append this to your package.json file, e.g.
"config": {
"bin-links": false
},
As said above, the synced/shared filesystem doesn't support symlinks.
SO, you can install node.js on your Windows host and execute npm install in the host code directory