我对 NodeJS 还很陌生,在安装保存到 package.json
文件的 classnames
包时遇到 npm 问题.
假设我有这个依赖项
列表:
"dependencies":
{
"classnames": "^2.1.2",
"jquery": "^2.1.3",
"sleep": "^1.2.0",
},
然后,当我运行 npm install
时,只有 jquery 和 sleep 被安装到 node_modules
文件夹中,而不是类名。但是,如果我手动运行 npm install classnames
,它会将该包下载到 node_modules 文件夹。
因此,我可以通过此解决方法在本地运行我的应用程序,但是当我将代码部署到 heroku 时,无论哪种方式都无法安装它,并且我的应用程序无法运行。
我尝试运行npm cache clean
,但没有帮助。这是特定classnames包的问题还是其他什么问题?
提前致谢。
最佳答案
终于可以解决这个问题了。这不仅仅是类名包的问题。
解决方案是在本地安装了我想要的所有软件包后运行npm Shrinkwrap
。然后提交所有内容(特别是包括 npm-shrinkwrap.json 中的更改)并推送到 heroku。
原因已经解释清楚here 。快速回顾:
When "npm install" installs a package with a npm-shrinkwrap.json file in the package root, the shrinkwrap file (rather than package.json files) completely drives the installation of that package and all of its dependencies (recursively).
关于node.js - 无法通过 npm 自动安装类名包(在 package.json 中定义),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30801169/