Skip to content

npm link not working on Node 6 #814

@jamestalmage

Description

@jamestalmage

To debug, I added the following statements to a number of internal AVA files:

console.log(__filename);

On Node 5, when everything works, I get this output:

/~/dev/ava/lib/fork.js
/~/dev/ava/lib/test-worker.js
/~/dev/ava/lib/test-worker.js
/~/dev/ava/lib/test-worker.js
/~/dev/ava/lib/test-worker.js
/~/dev/ava/index.js
/~/dev/ava/index.js
/~/dev/ava/index.js
/~/dev/ava/index.js
/~/dev/ava/index.js

On Node 6, where things are broken:

/~/dev/ava-codemods/node_modules/ava/lib/fork.js
/~/dev/ava/lib/test-worker.js
/~/dev/ava/lib/test-worker.js
/~/dev/ava/lib/test-worker.js
/~/dev/ava/lib/test-worker.js
/~/dev/ava-codemods/node_modules/ava/index.js
/~/dev/ava-codemods/node_modules/ava/index.js
/~/dev/ava-codemods/node_modules/ava/index.js
/~/dev/ava-codemods/node_modules/ava/index.js
/~/dev/ava-codemods/node_modules/ava/lib/test-worker.js
/~/dev/ava-codemods/node_modules/ava/lib/test-worker.js
/~/dev/ava-codemods/node_modules/ava/lib/test-worker.js
/~/dev/ava-codemods/node_modules/ava/index.js
/~/dev/ava-codemods/node_modules/ava/lib/test-worker.js

So, it appears that, in Node 6, npm linked modules think they are inside the node_modules folder of the project from which they are linked, instead of their actual path on the file system.

However, when we fork test-worker.js, it is aware of it's actual path. But that gets confused when when the user does require('ava') and the file paths show as nested again.

You will notice test-worker shows up twice as often as it should, with a deeper path the second time around.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions