安装后找不到节点私有模块

Cannot find node private modules after installing them

对于那些尝试在 npm 中编写私有模块的人,我遵循了这些说明 - https://docs.npmjs.com/private-modules/intro and https://docs.npmjs.com/getting-started/scoped-packages 但是当我需要它时我的项目似乎无法找到该项目,如下所示:

var projectName = require("@username/project-name");

我收到这个错误:

Cannot find module '@username/project-name'

我是不是漏掉了什么或者做错了什么?我所做的只是按照上述链接上的说明进行操作。

虽然我在安装过程中也遇到了一些问题,但我不知道为什么会这样:

npm WARN saveError Problems were encountered
npm WARN saveError Please correct and try again.
npm WARN saveError extraneous: browserify-ngannotate@1.0.1 /home/bassist/Workspace/test/test-web/node_modules/browserify-ngannotate
npm WARN saveError extraneous: browserify-shim@3.8.10 /home/bassist/Workspace/test/test-web/node_modules/browserify-shim
npm WARN saveError extraneous: karma-browserify@4.4.0 /home/bassist/Workspace/test/test-web/node_modules/karma-browserify
npm WARN saveError invalid: have pm2-deploy@0.2.1 (expected: latest) /home/bassist/Workspace/test/test-web/node_modules/pm2/node_modules/pm2-deploy
npm WARN saveError extraneous: pm2-deploy@0.2.1 /home/bassist/Workspace/test/test-web/node_modules/pm2/node_modules/pm2-deploy
npm WARN saveError extraneous: watchify@3.4.0 /home/bassist/Workspace/test/test-web/node_modules/watchify
tv4@1.0.18 node_modules/tv4 -> node_modules/pm2/node_modules/pm2-deploy/node_modules/tv4
test-web@0.2.49 /home/bassist/Workspace/test/test-web
└── @username/project-name@1.0.0 

npm WARN optional Skipping failed optional dependency /gulp-nodemon/nodemon/chokidar/fsevents:
npm WARN notsup Not compatible with your operating system or architecture: fsevents@1.0.6
npm WARN optional Skipping failed optional dependency /karma/chokidar/fsevents:
npm WARN notsup Not compatible with your operating system or architecture: fsevents@1.0.6
npm WARN optional Skipping failed optional dependency /karma-browserify/watchify/chokidar/fsevents:
npm WARN notsup Not compatible with your operating system or architecture: fsevents@1.0.6
npm WARN optional Skipping failed optional dependency /pm2/chokidar/fsevents:
npm WARN notsup Not compatible with your operating system or architecture: fsevents@1.0.6
npm WARN optional Skipping failed optional dependency /watchify/chokidar/fsevents:
npm WARN notsup Not compatible with your operating system or architecture: fsevents@1.0.6

编辑:我再次在我的主应用程序上重新安装了所有 node_modules 并安装了我的自定义模块,没有任何问题,但仍然无济于事..

这是我的 package.json 内容(在自定义模块上)

{
  "name": "@username/project-name",
  "version": "1.0.3",
  "description": "Separate module which can cater Mongo Data Service, and other services that access the Mongo database",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "Simon Guillen <simonbass@gmail.com>",
  "license": "ISC"
}

免责声明:我的项目是机密的,这就是为什么我使用 @username/package-name 作为我的示例范围模块名称的原因。

我解决了这个问题,问题在于没有将我的代码放在index.js中,因为我需要做的是将多个与数据相关的功能转移到一个包含3个文件的单独模块中。所以我不得不把这 3 个文件的代码堆积起来,然后把它们放在我的 index.js