node.js - npm @types 和 TypeScript 版本
问题描述
所以我们有一个问题,即在我们的构建机器上通过 npm 安装的文件与在我们开发人员的机器上本地使用的文件不同。
我们正在使用 TypeScript,所以需要@types
为一些 npm 包安装,所以在我们的 package.json 文件中,我们有......
"dependencies": {
"react-autosuggest": "^9.3.4"
}
"devDependencies": {
"@types/react-autosuggest": "^9.3.3"
}
在本地安装新的 npm 时,这是下拉类型文件,并在顶部的文件中显示;
// Type definitions for react-autosuggest 9.3
// Project: http://react-autosuggest.js.org/
// Definitions by: Nicolas Schmitt <https://github.com/nicolas-schmitt>
// Philip Ottesen <https://github.com/pjo256>
// Robert Essig <https://github.com/robessog>
// Terry Bayne <https://github.com/tbayne>
// Christopher Deutsch <https://github.com/cdeutsch>
// Kevin Ross <https://github.com/rosskevin>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.6
但是,构建服务器上的版本是;
// Type definitions for react-autosuggest 9.3
// Project: http://react-autosuggest.js.org/
// Definitions by: Nicolas Schmitt <https://github.com/nicolas-schmitt>
// Philip Ottesen <https://github.com/pjo256>
// Robert Essig <https://github.com/robessog>
// Terry Bayne <https://github.com/tbayne>
// Christopher Deutsch <https://github.com/cdeutsch>
// Kevin Ross <https://github.com/rosskevin>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.8
注意 TypeScript 的版本差异。
因此,无论出于何种原因,文件类型似乎都是相同的 9.3,但有些地方不太对劲。在本地,我们现在看到不同的行为与发布到实时环境的内容。
有人有什么想法吗?
解决方案
文件package.json
不存储具有子依赖项和版本的所有依赖项树。在 Node.js 生态系统中,有package-lock.json
/ yarn.lock
。
您应该将package-lock.json
/存储yarn.lock
在 git 存储库中以实现可重复性。
推荐阅读
- sql-server - 如何获取服务器上的所有 SQL 扩展事件会话?
- amazon-web-services - AWS EC2 实例被锁定 - 忘记 ssh 根密码?
- apache-kafka - 无法在 Windows 中使用 kafka cmd 创建消费者
- spring - Spring如何接收和回复
- python - 复选框总是在弹出窗口中读取 0 - Tkinter
- java - 并行 JobSteps 的 HSQLDB 序列化错误
- java - 如何在java中随时获取完整单词以使用缩写
- javascript - 使用 JavaScript 替换字符串中的未知特殊字符
- java - JSONObject from Google Maps parse in Java
- ms-access - Is there a way to pass parameters through an update query to a select query in Microsoft Access VBA using the execute command?