janniks / basetag

⚾️ A better way to import local NodeJS modules
MIT License
37 stars 3 forks source link

Could not find node_modules directory in __dirname on install #10

Closed nlipiarski closed 3 years ago

nlipiarski commented 4 years ago

Hello, I am using node v12.18.3 and npm version 6.14.6 on Windows When I try to install the package, I get the following message: `basetag@1.0.0

I'm not sure what seems to be causing this issue. I tried remove the node_modules folder and re-running npm i but that didn't seem to fix the issue. Any help would be greatly appreciated.

TheCodingDutchman commented 3 years ago

I'm pretty sure it doesn't work on Windows at all, it works fine on Linux. You can do it manually on Windows quite easily with this command: mklink /j "node_modules\$" .

janniks commented 3 years ago

We are working on a windows fix

coolaj86 commented 3 years ago

Imagine my great surprise to find that, indeed, @GameMaster2030 is correct:

Windows junctions can be used without super user privileges for directories in Windows 10. This is great news!

mklink /j "node_modules\$" .

However, it cannot be used with the built-in fs.symlink. I believe that is due to non-junction symlinks requiring admin privileges.

var fs = require('fs');
fs.mkdirSync("./node_modules", { recursive: true });
fs.symlinkSync("./node_modules/$", "../");

{
  errno: -4048,
  syscall: 'symlink',
  code: 'EPERM'
}

And although it appears that there's a 'junction' option, it didn't work for me.

You've got to shell out:

var exec = require('child_process').exec;
exec('mklink /j ".\\node_modules\\$" ".\\"', function (err, stdout, stderr) {
  console.log(err, stdout, stderr)
})

Note:

janniks commented 3 years ago

👋🏻 version 1.1.0 is live and supports Windows. Feel free to let me know if there are still any issues.