[英]My custom NPM Package is not found
Got very strange issues. 有非常奇怪的问题。 Basically i decided create my own npm package, and publish it to the world.
基本上,我决定创建自己的npm软件包,并将其发布给全世界。 During development, I was testing it as s simple node module, and was able to use it using next code:
在开发过程中,我将其作为简单的节点模块进行了测试,并能够通过以下代码使用它:
var r = require('./lib/%mymodulename%');
Of course it was in the lib folder. 当然它在lib文件夹中。
Now, I organised it as a npm package, and my package.json looks next: 现在,我将其组织为npm软件包,然后package.json看起来如下:
{
"name": "mymodulename",
"author": "xxx",
"description": "xxx",
"version": "0.0.1",
"homepage": "xxx",
"repository": {
"type": "git",
"url": "xxx"
},
"main": "/lib/mymodulename.js",
"scripts": {
"install":"node install.js"
},
"dependencies": {},
"engines": {
"node": ">=0.9"
}
}
when i am trying to test it via : npm install . -g
当我尝试通过以下方式对其进行测试时:
npm install . -g
npm install . -g
it is installed successfully and i am able to see my local module via: npm install . -g
它安装成功,我可以通过以下方式查看我的本地模块:
npm ls -g
however, when i am trying to use it in node file like: 但是,当我尝试在节点文件中使用它时,例如:
var r = require('mymodulename')
npm can't find it. var r = require('mymodulename')
npm找不到它。
I think that i am missing something very small, but can't find what. 我认为我缺少的东西很小,但是找不到。
Thanks, -D 感谢:D
Ok! 好! Thanks for the answers.
感谢您的回答。
It was totally my fault, and never put /
for the main
. 这完全是我的错,而从来没有把
/
的main
。
In my case i got : 就我而言:
"main": "/lib/mymodulename.js",
and it should be: 它应该是:
"main": "lib/mymodulename.js",
Thanks! 谢谢!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.