[英]npm private module not finding module
I have just started using npm private modules, and cannot pick up the module in my code. 我刚开始使用npm私有模块,无法在我的代码中获取模块。
The module is up and running on npmjs, I can install it correctly, but my require statement is failing. 该模块已在npmjs上运行,我可以正确安装,但我的require语句失败了。
My username has a dot in it. 我的用户名中有一个点。
I'm running os-x. 我正在运行os-x。
So the module is @user.name/my-module-name
. 所以模块是
@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. 我正在做一个
npm i --save @user.name/my-module-name
,它正确设置package.json,使用当前版本等,并将模块拉入我的./node_modules目录。
Error here: When I do the require('@user.name/my-module-name')
however, I'm getting a Cannot find module
error. 这里出错:当我执行
require('@user.name/my-module-name')
时,我得到一个Cannot find module
错误。
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? 如何从代码中获取模块?
To answer my own question, set the package.json::main property to the relevant file: 要回答我自己的问题,请将package.json :: main属性设置为相关文件:
"main": "./src/largestHref.js"
It was finding the module, but not the code... 它找到了模块,但没有找到代码......
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.