Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nlc with npm-prefix no such file or directory #8

Closed
keyoke opened this issue Sep 1, 2020 · 6 comments
Closed

nlc with npm-prefix no such file or directory #8

keyoke opened this issue Sep 1, 2020 · 6 comments

Comments

@keyoke
Copy link

keyoke commented Sep 1, 2020

Hi,
This is a useful tool, I'm currently running into an issue with the tool around npm prefixes
when running

nlc [linked package]

I get the following error-

Error: ENOENT: no such file or directory, stat 'C:\Users\VssAdministrator\AppData\Roaming\npm\node_modules[linked package]'
npm ERR! code ELIFECYCLE
npm ERR! errno 1

The link was successfully created

npm WARN [linked package]@1.0.0 No description
npm WARN [linked package]@1.0.0 No repository field.

audited 84 packages in 0.838s

3 packages are looking for funding
run npm fund for details

found 0 vulnerabilities

C:\npm\prefix\node_modules[linked package] -> D:\a\1\s\libs[linked package]

am running this on a build agent which seems to have a global prefix defined, , If I configure the same scenario on my local dev machine I get the same error.

Many Thanks
Gareth

@laggingreflex
Copy link
Owner

Firstly, are you sure your [linked package] is actually npm-linked, i.e. have you run npm link from inside your [linked package]? Sorry for asking, I know you specifically wrote "linked", but just to be sure..

Second, have you set a custom prefix-path in your .npmrc? If so could you share your config? I faced a similar issue while doing just that, and I think it's probably a problem that needs to be addressed in jonschlinkert/global-modules#13. Although in my case it was specifically about me using a tilde "~" in my path, which doesn't seem to be the cause in your case, but perhaps a similar problem of using some other form of custom path that also doesn't work with global-modules..?

And how about other commands: npm-link-save, and npm-link-quick, are those working as expected or are you getting the same error with them too?

@keyoke
Copy link
Author

keyoke commented Sep 2, 2020

Thanks I missed the relationship between global-modules & global prefix libraries. Yes I'm definitely linking before calling nlc. In this scenario I'm using hosted build agents provided by Azure DevOps. In the past the npm config on agent images was setup with this script - https://github.com/microsoft/azure-pipelines-image-generation/blob/83eb28f760cb8ecd808eb9f6f740a854398ebb99/images/win/scripts/Installers/Install-NodeLts.ps1

$PrefixPath = 'C:\npm\prefix'
$CachePath = 'C:\npm\cache'

New-Item -Path $PrefixPath -Force -ItemType Directory
New-Item -Path $CachePath -Force -ItemType Directory

choco install nodejs-lts -y --force

Add-MachinePathItem $PrefixPath
$env:Path = Get-MachinePath

setx NPM_CONFIG_PREFIX $PrefixPath /M
$env:NPM_CONFIG_PREFIX = $PrefixPath

setx NPM_CONFIG_CACHE $CachePath /M
$env:NPM_CONFIG_CACHE = $CachePath

npm config set registry http://registry.npmjs.org/

Thanks

@laggingreflex
Copy link
Owner

laggingreflex commented Sep 2, 2020

Ah, I see the problem. You're using the environment variable NPM_CONFIG_PREFIX to set the npm prefix-path. That's something that doesn't (yet) seem to be supported by the dependency I'm using to get the prefix path. It seems to have been discussed there though: jonschlinkert/global-prefix#5 (comment).

Actually I notice it reads the env var PREFIX (just that, not the full NPM_CONFIG_PREFIX) here. Can you switch to using PREFIX instead? That might work.

Or I'll see if I can/should implement getting prefix-path on my own in this library itself. Simply getting it via npm config get prefix command ought to do it. It even seems to handle nicely my tilde ~ use case I mentioned above.

@laggingreflex
Copy link
Owner

Did just that 29dcbb4. Published v0.5.0

That should fix this. Please reopen if not.

@keyoke
Copy link
Author

keyoke commented Sep 2, 2020

awsome will test

@sahilrajput03
Copy link

This is a really good library, I use it regularly, its awesome!!!.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants