Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

npm private module not finding module

Tags:

node.js

npm

I have just started using npm private modules, and cannot pick up the module in my code.

The module is up and running on npmjs, I can install it correctly, but my require statement is failing.

My username has a dot in it.

I'm running os-x.

So the module is @user.name/my-module-name.

I am doing an npm i --save @user.name/my-module-name, which is setting the package.json correctly, with current versions and so on, and pulling the module into my ./node_modules dir.

Error here: When I do the require('@user.name/my-module-name') however, I'm getting a Cannot find module error.

I have tried escaping parts of the name, and addressing it directly, to no avail. This feels like a node problem.

How can I pick up the module from code?

like image 398
andrew oxenburgh Avatar asked Oct 30 '22 04:10

andrew oxenburgh


1 Answers

To answer my own question, set the package.json::main property to the relevant file:

"main": "./src/largestHref.js"

It was finding the module, but not the code...

like image 174
andrew oxenburgh Avatar answered Nov 12 '22 17:11

andrew oxenburgh