node.js - npm package works locally but modules cannot be resolved when published
问题描述
I wrote a little npm module. In the main index.js, I am requiring another js file like so:
const Interface = importJsx('./Interface');
interface.js is a functional react component which I am exporting by writing module.exports = Interface; at the end and is in the root folder, just like index.js. When I run node index.js on the command line, everything works. When I publish the module to npm and run npx MY_PACKAGE_NAME, all of a sudden 'Interface' cannot be resolved. What is the workaround for npm's busted file system?
解决方案
推荐阅读
- java - 如果 getter 被标记为同步,为什么这段代码会完成?
- java - Java:下载字符串 HTTP GET
- c# - 使用 C# 发送电子邮件的警报提醒时出错
- javascript - 如何根据 CSS+HTML 显示相对于单词的文本?
- django - django:非空约束失败
- ios - 存在 NSConstraintConflict 时显示 UIAlertController
- python - 如何在不覆盖最后一个字符串的情况下将用户的所有输入(字符串)附加到列表中
- r - 以分类变量作为因变量和混合自变量以及存在多重共线性的回归
- linux - 为什么 set-uid 程序从不创建程序所有者拥有且其他用户可写的文件?
- html - 如果 URL 不变,我应该使用按钮还是链接?