Skip to content

[Issue]: nvm4w can't install npm,because file path is not correct #1310

@arika163

Description

@arika163

What happened?

if i use nvm to install a node version,i get the output like below:

$ nvm install 13
Downloading node.js version 13.14.0 (64-bit)... 
Complete
Downloading npm...
Creating C:\Users\39638\AppData\Local\Temp\nvm-install-2940513581\temp

Downloading npm version 6.14.4... Complete
Installing npm v6.14.4...
error installing 13.14.0: open C:\Users\username\AppData\Local\Temp\nvm-npm-3142577732\npm-v6.14.4.zip: The system cannot find the file specified.

What did you expect to happen?

In nvm.go,starts from line745,nvm create a new temp dir,then nvm try to unzip an unexist zip file under this temp dir.Because the dir is empty,nvm throw an error

				// new temp directory under the nvm root
				tempDir, err := os.MkdirTemp("", "nvm-npm-*")
				if err != nil {
					status <- Status{Err: err}
				}
				defer os.RemoveAll(tempDir)
				// tempDir := filepath.Join(root, "temp")

				// Extract npm to the temp directory
				err = file.Unzip(filepath.Join(tempDir, "npm-v"+npmv+".zip"), filepath.Join(tempDir, "nvm-npm"))

Version

1.2.0 or newer (Default)

Which version of Windows?

Windows 11+ (Default)

Which locale?

None

Which shell are you running NVM4W in?

Other

User Permissions?

Administrative Privileges, Elevated

Is Developer Mode enabled?

None

Relevant log/console output

Downloading node.js version 13.14.0 (64-bit)... 
Complete
Downloading npm...
Creating C:\Users\39638\AppData\Local\Temp\nvm-install-2940513581\temp

Downloading npm version 6.14.4... Complete
Installing npm v6.14.4...
error installing 13.14.0: open C:\Users\username\AppData\Local\Temp\nvm-npm-3142577732\npm-v6.14.4.zip: The system cannot find the file specified.

Debug Output

none

Anything else?

already fix it by add code below:

				// new temp directory under the nvm root
				// tempDir, err := os.MkdirTemp("", "nvm-npm-*")
				// if err != nil {
				// 	status <- Status{Err: err}
				// }
				// defer os.RemoveAll(tempDir)
				tempDir := filepath.Join(root, "temp")  // i add this line

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions