在阅读npm-json(npm help json
)之后,我构建了package.json
文件,如下所示:{"name": "app name", "version": "0.1"}
。该目录具有以下结构:
/
|-- main.js
|-- package.json
我熟悉Node.js - do I need to reinstall all the modules on the production server when deploying the Node.js app,因此我尝试通过执行npm install moduleDep --save
来安装依赖项,但是我收到以下错误:
0 info it worked if it ends with ok
1 verbose cli [ 'node', '/usr/local/bin/npm', 'install', 'jquery', '--save' ]
2 info using npm@1.2.2
3 info using node@v0.8.18
4 verbose read json /home/roth/develop/build/package.json
5 error Error: invalid version: 1
5 error at validVersion (/usr/local/lib/node_modules/npm/node_modules/read-package-json/read-json.js:582:40)
5 error at final (/usr/local/lib/node_modules/npm/node_modules/read-package-json/read-json.js:342:23)
5 error at /usr/local/lib/node_modules/npm/node_modules/read-package-json/read-json.js:140:33
5 error at cb (/usr/local/lib/node_modules/npm/node_modules/slide/lib/async-map.js:48:11)
5 error at /usr/local/lib/node_modules/npm/node_modules/read-package-json/read-json.js:320:48
5 error at fs.js:117:20
5 error at /usr/local/lib/node_modules/npm/node_modules/graceful-fs/graceful-fs.js:53:5
5 error at /usr/local/lib/node_modules/npm/node_modules/graceful-fs/graceful-fs.js:62:5
5 error at Object.oncomplete (fs.js:297:15)
6 error If you need help, you may report this log at:
6 error <http://github.com/isaacs/npm/issues>
6 error or email it to:
6 error <npm-@googlegroups.com>
7 error System Linux 3.1.10-1.16-desktop
8 error command "node" "/usr/local/bin/npm" "install" "jquery" "--save"
9 error cwd /home/roth/develop/build
10 error node -v v0.8.18
11 error npm -v 1.2.2
12 verbose exit [ 1, true ]
在运行main
模块之前,我必须使用NPM来安装依赖项。
是否有任何我可以执行的命令将安装然后将依赖项添加到package.json
?彻底的解释会很棒。
答案 0 :(得分:7)
Node.js使用3部分版本控制系统,如“0.0.1”或“1.2.3” - 你的“0.1”不起作用。这称为语义版本控制,详情请参见:
基本思想是你使用三个代表major,minor和patch(major.minor.patch)的数字。
您可以在此处阅读有关npm版本控制的更多内容: