My custom NPM Package is not found

ⅰ亾dé卋堺 提交于 2021-02-11 17:25:57

问题


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 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


回答1:


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!



来源:https://stackoverflow.com/questions/23018581/my-custom-npm-package-is-not-found

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!