I recently published a package to NPM. The package works well on my own computer, where I wrote the code, but upon npm install
on a coworkers machine, I start receiving errors.
我最近向NPM发布了一个包。该软件包在我自己的计算机上运行良好,我编写代码,但是在同事机器上安装npm后,我开始收到错误。
What is the best way to go about installing and testing my package on my own computer? I could trace through the errors on my coworkers computer, but I assume there is a way I can do this on my own machine.
在我自己的计算机上安装和测试我的软件包的最佳方法是什么?我可以追踪我的同事计算机上的错误,但我认为有一种方法可以在我自己的机器上执行此操作。
1 个解决方案
#1
1
- You don't have to install it on your own computer first if you want to test it, you could write unit tests instead, since you have to
require
the package if you do (just like an npm install). - 如果你想测试它,你不必先在自己的计算机上安装它,你可以编写单元测试,因为你必须要求包(就像npm安装一样)。
- Check the
package.json
to see if all needed modules are listed underdependencies
. (Delete the node_modules folder, runnpm install
and see what errors are given) - 检查package.json以查看依赖项下是否列出了所有需要的模块。 (删除node_modules文件夹,运行npm install并查看给出的错误)
- If there is a file called
.npmrc
, check what files/folders it lists to make sure it's not excluding important files from NPM. - 如果有一个名为.npmrc的文件,请检查它列出的文件/文件夹,以确保它不会从NPM中排除重要文件。
- Make sure your module has a
module.exports
object, to be able to access the objects/functions - 确保您的模块具有module.exports对象,以便能够访问对象/函数
If this all didn't help, it might be a more specific problem and a GitHub link would help us more
如果这一切都没有帮助,那可能是一个更具体的问题,GitHub链接可以帮助我们更多
#1
1
- You don't have to install it on your own computer first if you want to test it, you could write unit tests instead, since you have to
require
the package if you do (just like an npm install). - 如果你想测试它,你不必先在自己的计算机上安装它,你可以编写单元测试,因为你必须要求包(就像npm安装一样)。
- Check the
package.json
to see if all needed modules are listed underdependencies
. (Delete the node_modules folder, runnpm install
and see what errors are given) - 检查package.json以查看依赖项下是否列出了所有需要的模块。 (删除node_modules文件夹,运行npm install并查看给出的错误)
- If there is a file called
.npmrc
, check what files/folders it lists to make sure it's not excluding important files from NPM. - 如果有一个名为.npmrc的文件,请检查它列出的文件/文件夹,以确保它不会从NPM中排除重要文件。
- Make sure your module has a
module.exports
object, to be able to access the objects/functions - 确保您的模块具有module.exports对象,以便能够访问对象/函数
If this all didn't help, it might be a more specific problem and a GitHub link would help us more
如果这一切都没有帮助,那可能是一个更具体的问题,GitHub链接可以帮助我们更多