不能要求npm包

我正在构build一个我想发布的npm包。 我遵循这个指示 ,直到我到达require部分。 我用npm install . -g安装了这个包npm install . -g npm install . -g ,当我执行npm ls -g时,我可以看到它已经列出。 但是当我需要的时候,我得到了

 var VuePrint = require('vue-print') Error: Cannot find module 'vue-print' at Function.Module._resolveFilename (module.js:325:15) at Function.Module._load (module.js:276:25) at Module.require (module.js:353:17) at require (internal/module.js:12:17) at repl:1:16 at REPLServer.defaultEval (repl.js:252:27) at bound (domain.js:287:14) at REPLServer.runBound [as eval] (domain.js:300:12) at REPLServer.<anonymous> (repl.js:417:12) at emitOne (events.js:82:20) 

那是来自node-repl的错误,但是我在不同的堆栈跟踪环境中得到了相同的结果。 那么, 我如何要求我的软件包稍后发布? 这里是我的package.json文件的相关部分,以防万一

 { "name": "vue-print", "description": "Vue plugin to easy print in the web", "author": "YerkoPalma <yerko.palma@usach.cl>", "version": "0.1.3", "main": "dist/vueprint.js", "files": [ "dist/vueprint.js", "src", "README.md" ], "scripts": { "build": "cross-env NODE_ENV=production browserify -e src/vueprint.js | uglifyjs -c warnings=false -m > dist/vueprint.js", ... }, "browserify": { "transform": [ "vueify", "babelify" ] }, "repository": { "type": "git", "url": "git+https://github.com/YerkoPalma/vue-print.git" }, "bugs": { "url": "https://github.com/YerkoPalma/vue-print/issues" }, "dependencies": { "vue": "^1.0.0" }, "devDependencies": { ... } } 

您不需要将软件包安装为全局软件包(-g)。 只需要到你的项目文件夹(你想要使用vue-print)并运行命令“npm i vue-print”,然后你可以在这个文件夹中使用require('vue-print')