Skip to content


Subversion checkout URL

You can clone with
Download ZIP


npm link on windows #3108

TimNZ opened this Issue · 8 comments

5 participants


Is the following correct behaviour on Win7?


cd \source\my_app
npm link ..\my_package

c:\source\my_package is copied to c:\users\xxxxxx\AppData\Roaming\npm\node_modules\my_package

c:\users\xxxxxx\AppData\Roaming\npm\node_modules\my_package -> c:\source\my_app\node_modules\my_package

There is no mention in the documentation or output from npm link that the 'master' is now in App\Roaming.

This also screws up require resolution as the containing symlink dir (c:\source\my_app\node_modules) is not checked for resolving requires in my_package.

Hey, this may be a limitation of symlinks, but I'm keen for solutions on how to best manage this.


You aren't quite using npm link like you're supposed to. You need to run it once without arguments in the folder of the package you want to create a global link for, then again with the name of the package you want to link from global to local. See for more information.

@domenic domenic closed this

Eh? The docs quite clearly says I can use the shortcut 'npm link ' from the using package dir.

You may also shortcut the two steps in one. For example, to do the above use-case in a shorter way:

cd ~/projects/node-bloggy # go into the dir of your main project
npm link ../node-redis # link the dir of your dependency

Anyway, either way does not work.

When I run the main package, packages in main/node_modules are not resolved when the linked package requires them.

So either I mis-understand how linking works and when I can use it, or it's broken on Windows.


Linking certainly works on Windows, unless maybe you're on a version from a decade ago like Windows XP?

@domenic domenic reopened this

Nope Win7x64.

Here's a convulted simple example, detailed every step - if this works for you then it's my system.
With testmodule as regular dir under node_modules it works fine.

Clearly the base dir for resolving requires in testmodule is it's source location, not the symlink dir.

1) open cmd as administrator (required for symlink creation)
2) md linktest
3) create 'linktest\test.js'

var r = require('testmodule');

4) cd linktest
5) npm install lodash
6) cd ..
7) md testmodule
8) create 'testmodule\index.js'

var _ = require('lodash');
module.exports.test = function(t)

9) cd testmodule
10) npm link

C:\Users\xxxxxxx\AppData\Roaming\npm\node_modules\testmodule -> C:\Development\Projects\xxxxxxx\testmodule

11) cd ..\linktest
12) npm link testmodule

C:\Development\Projects\xxxxxxlinktest\node_modules\testmodule -> C:\Users\xxxxxxxx\AppData\Roaming\npm\node_modules\testmodule -> C:\Development\Projects\xxxxxx\testmodule

13) node test

    throw err;
Error: Cannot find module 'lodash'
    at Function.Module._resolveFilename (module.js:338:15)
    at Function.Module._load (module.js:280:25)
    at Module.require (module.js:364:17)
    at require (module.js:380:17)
    at Object.<anonymous> (C:\Development\Projects\xxxxx\testmodule\index.js:1:71)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Module.require (module.js:364:17)

This looks like a node/Windows issue anyway, as all npm is doing is creating the symlink.
Or as I said earlier, I don't understand how symlinks are supposed to work

@iarna iarna added the support label

Is this still a problem for you?

This looks like a bug report to me. I will try to reproduce it with the current version of node on Windows.


following the same process I get the same result on win 8.1, node v0.12.0


however, running npm link, and then npm link packageName does work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.