Nvm: --reinstall-packages-from fails: "Could not install from "" as it does not contain a package.json file"

Created on 23 Feb 2018  ·  22Comments  ·  Source: nvm-sh/nvm

  • Operating system and version: Fedora KDE 27

  • nvm debug output:


nvm --version: v0.33.8
$SHELL: /bin/bash
$HOME: /home/[my name]
$NVM_DIR: '$HOME/.nvm'
$PREFIX: ''
$NPM_CONFIG_PREFIX: ''
$NVM_NODEJS_ORG_MIRROR: ''
$NVM_IOJS_ORG_MIRROR: ''
shell version: 'GNU bash, version 4.4.19(1)-release (x86_64-redhat-linux-gnu)'
uname -a: 'Linux 4.14.18-300.fc27.x86_64 #1 SMP Thu Feb 8 01:35:31 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux'
OS version: 
curl: /usr/bin/curl, curl 7.55.1 (x86_64-redhat-linux-gnu) libcurl/7.55.1 OpenSSL/1.1.0g zlib/1.2.11 libidn2/2.0.4 libpsl/0.18.0 (+libidn2/2.0.3) libssh2/1.8.0 nghttp2/1.25.0
wget: /usr/bin/wget, GNU Wget 1.19.4 built on linux-gnu.
git: /usr/bin/git, git version 2.14.3
grep: alias grep='grep --color=auto'
        /usr/bin/grep (grep --color=auto), grep (GNU grep) 3.1
awk: /usr/bin/awk, GNU Awk 4.1.4, API: 1.1 (GNU MPFR 3.1.5, GNU MP 6.1.2)
sed: /usr/bin/sed, sed (GNU sed) 4.4
cut: /usr/bin/cut, cut (GNU coreutils) 8.27
basename: /usr/bin/basename, basename (GNU coreutils) 8.27
rm: /usr/bin/rm, rm (GNU coreutils) 8.27
mkdir: /usr/bin/mkdir, mkdir (GNU coreutils) 8.27
xargs: /usr/bin/xargs, xargs (GNU findutils) 4.6.0
nvm current: v9.6.1
which node: $NVM_DIR/versions/node/v9.6.1/bin/node
which iojs: which: no iojs in (/opt/OpenPrinting-Gutenprint/sbin:/opt/OpenPrinting-Gutenprint/bin:$NVM_DIR/versions/node/v9.6.1/bin:/usr/lib64/qt-3.3/bin:/opt/OpenPrinting-Gutenprint/sbin:/opt/OpenPrinting-Gutenprint/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:$HOME/.local/bin:$HOME/bin)
which npm: $NVM_DIR/versions/node/v9.6.1/bin/npm
npm config get prefix: $NVM_DIR/versions/node/v9.6.1
npm root -g: $NVM_DIR/versions/node/v9.6.1/lib/node_modules

  • nvm ls output:

         v9.6.0
->       v9.6.1
default -> v9.6.0
node -> stable (-> v9.6.1) (default)
stable -> 9.6 (-> v9.6.1) (default)
iojs -> N/A (default)
lts/* -> lts/carbon (-> N/A)
lts/argon -> v4.8.7 (-> N/A)
lts/boron -> v6.13.0 (-> N/A)
lts/carbon -> v8.9.4 (-> N/A)

  • How did you install nvm? (e.g. install script in readme, homebrew): Install script I believe. It's been a while.

  • What steps did you perform?

  • nvm ls-remote
  • See there is a new version, e.g. v9.6.1
  • nvm install v9.6.1 --reinstall-packages-from=v9.6.0

  • What happened?

Downloading and installing node v9.6.1...
Downloading https://nodejs.org/dist/v9.6.1/node-v9.6.1-linux-x64.tar.xz...
######################################################################## 100.0%
Computing checksum with sha256sum
Checksums matched!
Now using node v9.6.1 (npm v5.6.0)
Reinstalling global packages from v9.6.0...
npm ERR! code ENOLOCAL
npm ERR! Could not install from "" as it does not contain a package.json file.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/[my name]/.npm/_logs/2018-02-23T15_26_22_862Z-debug.log
Linking global packages from v9.6.0...
  • What did you expect to happen?
    Just install any previous packages like normal. This used to work fine on Ubuntu but I am on Fedora now, not sure if that makes a difference.

  • Is there anything in any of your profile files (.bashrc, .bash_profile, .zshrc, etc) that modifies the PATH?
    No.

bugs installing node pull request wanted

All 22 comments

@steelstring94 can you print the content of /home/[my name]/.npm/_logs/2018-02-23T15_26_22_862Z-debug.log?

I tested with the latest Fedora 27 Docker image but can't reproduce this problem.

@PeterDaveHello Can you do me a favor and censor my name out of your post? I tried to censor it in my OP but I missed one.

0 info it worked if it ends with ok
1 verbose cli [ '/home/[my name]/.nvm/versions/node/v9.6.1/bin/node',
1 verbose cli   '/home/[my name]/.nvm/versions/node/v9.6.1/bin/npm',
1 verbose cli   'install',
1 verbose cli   '-g',
1 verbose cli   '--quiet' ]
2 info using [email protected]
3 info using [email protected]
4 verbose npm-session 7882bbe438c61849
5 silly install loadCurrentTree
6 silly install readGlobalPackageData
7 silly fetchPackageMetaData error for file: Could not install from "" as it does not contain a package.json file.
8 verbose stack Error: ENOENT: no such file or directory, open '/home/[my name]/package.json'
9 verbose cwd /home/[my name]
10 verbose Linux 4.14.18-300.fc27.x86_64
11 verbose argv "/home/[my name]/.nvm/versions/node/v9.6.1/bin/node" "/home/[my name]/.nvm/versions/node/v9.6.1/bin/npm" "install" "-g" "--quiet"
12 verbose node v9.6.1
13 verbose npm  v5.6.0
14 error code ENOLOCAL
15 error Could not install from "" as it does not contain a package.json file.
16 verbose exit [ 1, true ]

@steelstring94 what about the output of nvm_npm_global_modules v9.6.0?

Just to confirm, is this output the raw or the modified? I wonder about the "" here:
npm ERR! Could not install from "" as it does not contain a package.json file.

nvm_npm_global_modules v9.6.0 output is ////. It is the exact same, by the way, if I use v9.6.1 as the argument.

And yes, that output is raw. It really does have two empty double quotes.

Looks like nvm didn't fetch the installed packages properly, what about npm list -g --depth=0?

/home/[my name]/.nvm/versions/node/v9.6.1/lib
└── [email protected]

That seems correct to me; that means there's no non-npm global modules installed.

It seems like the logic here doesn't actually check for "no installs" - the fix is likely as simple as wrapping https://github.com/creationix/nvm/blob/master/nvm.sh#L3341-L3342 in if [ -n "${INSTALLS}" ]; then and https://github.com/creationix/nvm/blob/master/nvm.sh#L3344-L3345 in if [ -n ${LINKS}" ]; then, and outputting appropriate messages else that nothing was found.

Looks like you're using a manually installed very new npm version?

I assume @steelstring94 has something to be installed so you'd like to use that parameter to install the old packages?

@PeterDaveHello "Looks like you're using a manually installed very new npm version?" - not as far as I'm aware. I'm pretty sure this is just what came with NVM.

@steelstring94 it's not; 5.6.0 is the "latest" npm. you may have run nvm install-latest-npm or npm upgrade -g tho?

@ljharb I have used npm update -g

So besides npm update -g, did you install any other packages?

@PeterDaveHello I don't believe so. It's difficult for me to say 100% as I didn't expect this to happen so I wasn't particularly keeping track of whether I installed anything, but I switched to a new distro not long ago and I don't think I've used any NPM global packages on here yet.

because if you didn't install anything, you don't need to use --reinstall-packages-from, though I agree that nvm should notice that nothing is installed and prevent to call npm in this case, to avoid this problem.

@steelstring94 fwiw, don’t use npm update -g; use nvm install-latest-npm or `npm install -g npmrc; that way you won’t get unstable versions.

@ljharb I thought npm update -g was to install the latest versions of global packages you have installed with npm? Am I wrong?

Yes, but that will also update npm; it’s best to update your global packages (of which there should be few) manually.

I was facing the same issue in windows 10, when my user folder has space in folder name
"C:\Users\Ibrar Hussain", I rename it to "C:\Users\IbrarHussain" and now its working fine.
you can Google it to rename the user folder. https://www.google.com/search?q=how+to+rename+user+folder+in+windows+10

@imibrar that seems like it's worth a separate bug. Can you file one?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

gsklee picture gsklee  ·  4Comments

danielepolencic picture danielepolencic  ·  4Comments

ksmithut picture ksmithut  ·  3Comments

cdelorme picture cdelorme  ·  5Comments

swateek picture swateek  ·  3Comments