Got very strange issues. Basically i decided create my own npm package, and publish it to the world. 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.
Now, I organised it as a npm package, and my package.json looks next:
{
"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
it is installed successfully and i am able to see my local module via:
npm ls -g
however, when i am trying to use it in node file like:
var r = require('mymodulename')
npm can't find it.
I think that i am missing something very small, but can't find what.
Thanks, -D
Ok! Thanks for the answers.
It was totally my fault, and never put /
for the main
.
In my case i got :
"main": "/lib/mymodulename.js",
and it should be:
"main": "lib/mymodulename.js",
Thanks!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.