I can't install my npm package globally - node.js

I want to create npm package that can be installed globally. I can publish the package, publish new version, but when I want to install it globally, it is not working.
yarn global add <package> outputs:
success Installed "pentest-tool-lite#0.0.3" with binaries:
- pentest-tool-lite
npm install -g <package> outputs:
npm ERR! path /nvm/versions/node/v8.7.0/lib/node_modules/pentest-tool-lite/lib/index
npm ERR! code ENOENT
npm ERR! errno -2
npm ERR! syscall chmod
npm ERR! enoent ENOENT: no such file or directory, chmod 'nvm/versions/node/v8.7.0/lib/node_modules/pentest-tool-lite/lib/index'
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! _logs/2017-12-03T16_00_34_926Z-debug.log
debug log:
7877 info linkStuff pentest-tool-lite#0.0.3
7878 silly linkStuff pentest-tool-lite#0.0.3 has /Users/juffalow/.nvm/versions/node/v8.7.0/lib/node_modules as its parent node_modules
7879 silly linkStuff pentest-tool-lite#0.0.3 is part of a global install
7880 silly linkStuff pentest-tool-lite#0.0.3 is installed into a global node_modules
7881 silly linkStuff pentest-tool-lite#0.0.3 is installed into the top-level global node_modules
7882 verbose linkBins pentest-tool-lite#0.0.3
7883 verbose linkBins [ { 'pentest-tool-lite': './lib/index' },
7883 verbose linkBins '/Users/juffalow/.nvm/versions/node/v8.7.0/bin',
7883 verbose linkBins true ]
7884 verbose linkMans pentest-tool-lite#0.0.3
7885 verbose unlock done using /Users/juffalow/.npm/_locks/staging-fa43d53d0ab27b11.lock for /Users/juffalow/.nvm/versions/node/v8.7.0/lib/node_modules/.staging
7886 verbose stack Error: ENOENT: no such file or directory, chmod '/Users/juffalow/.nvm/versions/node/v8.7.0/lib/node_modules/pentest-tool-lite/lib/index'
7887 verbose cwd /Users/juffalow/NetBeansProjects/pentest-tool-lite
7888 verbose Darwin 16.0.0
7889 verbose argv "/Users/juffalow/.nvm/versions/node/v8.7.0/bin/node" "/Users/juffalow/.nvm/versions/node/v8.7.0/bin/npm" "install" "-g" "pentest-tool-lite"
7890 verbose node v8.7.0
7891 verbose npm v5.4.2
7892 error path /Users/juffalow/.nvm/versions/node/v8.7.0/lib/node_modules/pentest-tool-lite/lib/index
7893 error code ENOENT
7894 error errno -2
7895 error syscall chmod
7896 error enoent ENOENT: no such file or directory, chmod '/Users/juffalow/.nvm/versions/node/v8.7.0/lib/node_modules/pentest-tool-lite/lib/index'
7897 error enoent This is related to npm not being able to find a file.
7898 verbose exit [ -2, true ]
Yarn seems to install it successfully, but not. NPM shows error but I really don't know why? Do you have any experience with module?

Ok, I found the problem. When you want to publish global module to npm, you have to publish build version ( e.g. bin or lib folder ). I had this version but ignored in .gitignore because it need not to be in repo. And when you don't have .npmignore npm uses .gitignore file, so the module was published without build version, therefore without executable files.
Solution: add .npmignore file to the root of the project with:
node_modules/
coverage/

Related

When upgrading node from 6 to latest, npm i fails with ENOENT in react native project

When upgrading to newer versions of npm from 6.14 to latest on react native project
Using node 14, nvm to switch node versions, ideally i'd like to go to node 16, but a similar issue happens regardless of 14 or 16 when updating npm in particular.
I'm also using homebrew on mac M1
I notice the Jetify command asks me:
Jetifier found 1390 file(s) to forward-jetify. Using 8 workers...
Need to install the following packages:
pod
Ok to proceed? (y)
when i select y, npm i fails. I've cleared cache's and removed node_modules. normal cache clearing attempts don't seem to work.
npm ERR! code ENOENT
npm ERR! syscall chmod
npm ERR! path /Users/user/.npm/_npx/a0ca5f5666585aa2/node_modules/pod/node_modules/pm2/bin/pm2
npm ERR! errno -2
npm ERR! enoent ENOENT: no such file or directory, chmod '/Users/user/.npm/_npx/a0ca5f5666585aa2/node_modules/pod/node_modules/pm2/bin/pm2'
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/user/.npm/_logs/2022-01-28T21_51_28_303Z-debug-0.log
npm ERR! code 254
npm ERR! path /Users/user/repos/MyApp/My-MobileApp
npm ERR! command failed
npm ERR! command sh -c npx jetify && cd ios && npx pod install && cd .. && ./node_modules/.bin/patch-package
Here is part of the complete log -
3325 timing reify:rollback:retireShallow Completed in 0ms
3326 timing command:exec Completed in 42372ms
3327 verbose stack Error: ENOENT: no such file or directory, chmod '/Users/user/.npm/_npx/a0ca5f5666585aa2/node_modules/pod/node_modules/pm2/bin/pm2'
3328 verbose cwd /Users/user/repos/MyApp/MyApp-MobileApp/ios
3329 verbose Darwin 21.2.0
3330 verbose argv "/Users/user/.nvm/versions/node/v14.18.3/bin/node" "/Users/user/.nvm/versions/node/v14.18.3/lib/node_modules/npm/bin/npm-cli.js" "exec" "--" "pod" "install"
3331 verbose node v14.18.3
3332 verbose npm v8.4.0
3333 error code ENOENT
3334 error syscall chmod
3335 error path /Users/user/.npm/_npx/a0ca5f5666585aa2/node_modules/pod/node_modules/pm2/bin/pm2
3336 error errno -2
3337 error enoent ENOENT: no such file or directory, chmod '/Users/user/.npm/_npx/a0ca5f5666585aa2/node_modules/pod/node_modules/pm2/bin/pm2'
3338 error enoent This is related to npm not being able to find a file.
3338 error enoent
3339 verbose exit -2
3340 timing npm Completed in 42533ms
3341 verbose unfinished npm timer reify 1643406718315
3342 verbose unfinished npm timer reify:build 1643406730346
3343 verbose unfinished npm timer build 1643406730346
3344 verbose unfinished npm timer build:deps 1643406730347
3345 verbose unfinished npm timer build:link 1643406730354
3346 verbose unfinished npm timer build:link:node_modules/pod 1643406730356
3347 verbose code -2
3348 error A complete log of this run can be found in:
3348 error /Users/user/.npm/_logs/2022-01-28T21_51_28_303Z-debug-0.log
It looks like the error is related to not finding the pm2 package from pod dependency.
Not sure if this will work properly with npx, you might need to install pod globally to get this working.
npm install pod -g
pod install // instead of npx pod install
https://www.npmjs.com/package/pod#installation
Try npm rebuild they say to use "only when you upgrade the node version and must recompile"
hello i once faced this type of issue and issue was actually because pm2 or some other package or processes on old node which was used in your app wasnt found in the updated node version
Reinstall your pm2 package and other package used by your old node in your code again and try again
let me know if this helps you

npm init doesn't work, ENOENT: no such file or directory

I install node 14(LTS) on my window10, and npm is auto install, but npm init isn't work.
I check version of them is work
C:\Users\RURU\Documents\practice\css> node -v
// 14.4
C:\Users\RURU\Documents\practice\css> npm -v
// 6
but, npm init does't work, when I want to init a package.json.
C:\Users\RURU\Documents\practice\css> npm init # neither npm init -y
Error :
npm ERR! code ENOENT
npm ERR! syscall open
npm ERR! path C:\Users\RURU\Documents\practice\css\package.json
npm ERR! errno -4058
npm ERR! enoent ENOENT: no such file or directory, open 'C:\Users\RURU\Documents\practice\css\package.json'
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\RURU\AppData\Local\npm-cache\_logs\2021-07-04T14_37_28_289Z-debug.log
Error log:
0 info it worked if it ends with ok
1 verbose cli [
1 verbose cli 'C:\\Program Files\\nodejs\\node.exe',
1 verbose cli 'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli 'init'
1 verbose cli ]
2 info using npm#6.14.13
3 info using node#v14.17.2
4 silly package data {
4 silly package data name: 'c',
4 silly package data version: '1.0.0',
4 silly package data description: '',
4 silly package data main: 'index.js',
4 silly package data scripts: { test: 'echo "Error: no test specified" && exit 1' },
4 silly package data author: 'ru',
4 silly package data license: 'ISC'
4 silly package data }
5 info init written successfully
6 verbose stack Error: ENOENT: no such file or directory, open 'C:\Users\RURU\Documents\practice\css\package.json'
7 verbose cwd C:\Users\RURU\Documents\practice\css
8 verbose Windows_NT 10.0.19042
9 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "init"
10 verbose node v14.17.2
11 verbose npm v6.14.13
12 error code ENOENT
13 error syscall open
14 error path C:\Users\RURU\Documents\practice\css\package.json
15 error errno -4058
16 error enoent ENOENT: no such file or directory, open 'C:\Users\RURU\Documents\practice\css\package.json'
17 error enoent This is related to npm not being able to find a file.
18 verbose exit [ -4058, true ]
I dont't know how to fix it, can anyone help, please ...
my path
C:\Program Files\nodejs\;C:\Users\RURU\AppData\Roaming\npm
You can use 2 things to solve the problem :
Start the cmd in administrator mode and try again.
Run the command using --unsafe-perms i.e. npm init --unsafe-perms
I don't think 2 step will be required in most of the cases.

npm install webpack --save-dev error

I download a demo "react-redux-demo",and when I use the commond "npm install webpack --save-dev" to install webpack, the error shows.
This is the log
8351 verbose unlock done using C:\Users\user\AppData\Roaming\npm-cache\_locks\staging-51622fc2de18aa59.lock for D:\work\test\react-redux-demo\node_modules\.staging
8352 warn The package history is included as both a dev and production dependency.
8353 warn The package react is included as both a dev and production dependency.
8354 warn The package react-router-config is included as both a dev and production dependency.
8355 warn The package react-router-native is included as both a dev and production dependency.
8356 verbose stack Error: ENOENT: no such file or directory, rename 'D:\work\test\react-redux-demo\node_modules\.staging\loader-utils-21a7d1c0\node_modules\big.js'
-> 'D:\work\test\react-redux-demo\node_modules\.staging\big.js-134af3f2'
8357 verbose cwd D:\work\test\react-redux-demo
8358 verbose Windows_NT
10.0.14393
8359 verbose argv "D:\\Program Files\\nodejs\\node.exe" "D:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "webpack" "--save-dev"
8360 verbose node v8.4.0
8361 verbose npm v5.3.0
8362 error path D:\work\test\react-redux-demo\node_modules\.staging\loader-utils-21a7d1c0\node_modules\big.js
8363 error code ENOENT
8364 error errno -4058
8365 error syscall rename
8366 error enoent ENOENT: no such file or directory, rename 'D:\work\test\react-redux-demo\node_modules\.staging\loader-utils-21a7d1c0\node_modules\big.js'
-> 'D:\work\test\react-redux-demo\node_modules\.staging\big.js-134af3f2'
8367 error enoent This is related to npm not being able to find a file.
8368 verbose exit [ -4058, true ]

Heroku npm bower issue mean stack app

I keep trying to push to heroku with no success. I have tried modifying the .gitignore file, sticking to node version 10, clearing npm cache, trying to stage instead of production, getting frustrated please help!
-----> Node.js app detected
-----> Resetting git environment
-----> Requested node range: 0.10.x
-----> Resolved node version: 0.10.35
-----> Downloading and installing node
-----> Found existing node_modules directory; skipping cache
-----> Rebuilding any native dependencies
npm ERR! Error: ENOENT, chmod '/tmp/build_b8036af8fa11d1792ae4d166a4eaaf9a/node_modules/bower/node_modules/bower-registry-client/node_modules/request/node_modules/node-uuid/bin/uuid'
npm ERR! If you need help, you may report this *entire* log,
npm ERR! including the npm and node versions, at:
npm ERR! <http://github.com/npm/npm/issues>
npm ERR! System Linux 3.8.11-ec2
npm ERR! command "/tmp/build_b8036af8fa11d1792ae4d166a4eaaf9a/vendor/node/bin/node" "/tmp/build_b8036af8fa11d1792ae4d166a4eaaf9a/vendor/node/bin/npm" "rebuild"
npm ERR! cwd /tmp/build_b8036af8fa11d1792ae4d166a4eaaf9a
npm ERR! node -v v0.10.35
npm ERR! npm -v 1.4.28
npm ERR! path /tmp/build_b8036af8fa11d1792ae4d166a4eaaf9a/node_modules/bower/node_modules/bower-registry-client/node_modules/request/node_modules/node-uuid/bin/uuid
npm ERR! code ENOENT
npm ERR! errno 34
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /tmp/build_b8036af8fa11d1792ae4d166a4eaaf9a/npm-debug.log
npm ERR! not ok code 0
0 info it worked if it ends with ok
1 verbose cli [ '/tmp/build_b8036af8fa11d1792ae4d166a4eaaf9a/vendor/node/bin/node',
1 verbose cli '/tmp/build_b8036af8fa11d1792ae4d166a4eaaf9a/vendor/node/bin/npm',
1 verbose cli 'rebuild' ]
2 info using npm#1.4.28
3 info using node#v0.10.35
4 info readInstalled object
5 verbose rebuild path, id [ '/tmp/build_b8036af8fa11d1792ae4d166a4eaaf9a', 'cake#1.0.0' ]
6 verbose rebuild path, id [ '/tmp/build_b8036af8fa11d1792ae4d166a4eaaf9a/node_modules/bower',
6 verbose rebuild 'bower#1.3.12' ]
7 verbose rebuild path, id [ '/tmp/build_b8036af8fa11d1792ae4d166a4eaaf9a/node_modules/bower/node_modules/abbrev',
7 verbose rebuild 'abbrev#1.0.5' ]
8 verbose rebuild path, id [ '/tmp/build_b8036af8fa11d1792ae4d166a4eaaf9a/node_modules/bower/node_modules/archy',
8 verbose rebuild 'archy#0.0.2' ]
9 verbose rebuild path, id [ '/tmp/build_b8036af8fa11d1792ae4d166a4eaaf9a/node_modules/bower/node_modules/bower-config',
9 verbose rebuild 'bower-config#0.5.2' ]
10 verbose rebuild path, id [ '/tmp/build_b8036af8fa11d1792ae4d166a4eaaf9a/node_modules/bower/node_modules/bower-config/node_modules/graceful-fs',
10 verbose rebuild 'graceful-fs#2.0.3' ]
11 verbose rebuild path, id [ '/tmp/build_b8036af8fa11d1792ae4d166a4eaaf9a/node_modules/bower/node_modules/mout',
11 verbose rebuild 'mout#0.9.1' ]
.......
667 verbose linkMans node-uuid#1.4.2
668 verbose rebuildBundles node-uuid#1.4.2
669 error Error: ENOENT, chmod '/tmp/build_b8036af8fa11d1792ae4d166a4eaaf9a/node_modules/bower/node_modules/bower-registry-client/node_modules/request/node_modules/node-uuid/bin/uuid'
670 error If you need help, you may report this *entire* log,
670 error including the npm and node versions, at:
670 error <http://github.com/npm/npm/issues>
671 error System Linux 3.8.11-ec2
672 error command "/tmp/build_b8036af8fa11d1792ae4d166a4eaaf9a/vendor/node/bin/node" "/tmp/build_b8036af8fa11d1792ae4d166a4eaaf9a/vendor/node/bin/npm" "rebuild"
673 error cwd /tmp/build_b8036af8fa11d1792ae4d166a4eaaf9a
674 error node -v v0.10.35
675 error npm -v 1.4.28
676 error path /tmp/build_b8036af8fa11d1792ae4d166a4eaaf9a/node_modules/bower/node_modules/bower-registry-client/node_modules/request/node_modules/node-uuid/bin/uuid
677 error code ENOENT
678 error errno 34
679 verbose exit [ 34, true ]
! Push rejected, failed to compile Node.js app

not able to install npm without sudo

I've installed node into a custom directory in my home folder called local per these instructions : https://gist.github.com/isaacs/579814
I've added the location to my PATH and it seems to work fine. I cannot however seem to get npm to install without sudo. From what I can tell it is trying to execute a command in /bin folder.
The command I am running from ~/local/npm is make install and I got the latest versions of both node and npm from github.
Can anyone assist here?
user#localhost [~/local/npm]# make install
rm -rf \
.building_ronn \
html/doc \
html/api \
man
scripts/doc-build.sh doc/api/npm-view.md man/man3/npm-view.3
make[1]: Entering directory `/home1/extrabol/local/npm'
node cli.js install ronn --no-global
npm ERR! Error: EROFS, mkdir '/bin/node'
npm ERR! at Error (native)
npm ERR! If you need help, you may report this *entire* log,
npm ERR! including the npm and node versions, at:
npm ERR! <http://github.com/npm/npm/issues>
npm ERR! System Linux 3.4.87-20140414.1.bh6.x86_64
npm ERR! command "node" "/home1/extrabol/local/npm/cli.js" "install" "ronn" "--no-global"
npm ERR! cwd /home1/extrabol/local/npm
npm ERR! node -v v0.11.14-pre
npm ERR! npm -v 1.4.10
npm ERR! path /bin/node
npm ERR! code EROFS
npm ERR! errno -30
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /home1/extrabol/local/npm/npm-debug.log
npm ERR! not ok code 0
The Debug Log reports this
0 info it worked if it ends with ok
1 verbose cli [ 'node',
1 verbose cli '/home1/extrabol/local/npm/cli.js',
1 verbose cli 'install',
1 verbose cli 'ronn',
1 verbose cli '--no-global' ]
2 info using npm#1.4.10
3 info using node#v0.11.14-pre
4 verbose node symlink /home1/extrabol/local/node/node
5 error Error: EROFS, mkdir '/bin/node'
5 error at Error (native)
6 error If you need help, you may report this *entire* log,
6 error including the npm and node versions, at:
6 error <http://github.com/npm/npm/issues>
7 error System Linux 3.4.87-20140414.1.bh6.x86_64
8 error command "node" "/home1/extrabol/local/npm/cli.js" "install" "ronn" "--no-global"
9 error cwd /home1/extrabol/local/npm
10 error node -v v0.11.14-pre
11 error npm -v 1.4.10
12 error path /bin/node
13 error code EROFS
14 error errno -30
Figured it out. Looks like when I git cloned the npm files somehow I didn't have ownership over all of the files. a quick chown -R on the npm folder fixed the issue.

Resources