0

I have two directory structure: The first one, which is my utils project is like this

mock-utils:   
   app-mock (symlinked to app-mock)
   common
       utils.js
   node_modules
   package.json
   package-lock.json

I have another one which is the app-mock which is somewhere locally,

app-mock:
  tests
      test.js

test.js contains the following import, and the entry point for the execution is inside the mock-utils since package.json is located there:

var mocha = require('mocha');
var shield = require(‘../../common/utils.js’)

However, executing test.js from mock-utils will give the error of Error: Cannot find module

Originally, app-mock is inside the mock-utils but it have to be separated for git. How do I adjust it so that it would be possible to execute test.js while retaining this kind of structure?

Carlos Miguel Colanta
  • 2,685
  • 3
  • 31
  • 49

1 Answers1

0

You can find a solution here: Installing a local module using npm?

Please note that due to recent NPM updates you might need to remove you package-lock.json file for this to work. Avoid running npm install during your development because this will recreate the package-lock.json file and npm will try to replace your symlinked package with the real one which, with your current setup, from what i understand, will throw a package not found exception.