这几天在做一个简单的文本编辑器,用到时simditor这个框架,使用npm安装后会增加几个对应的模块,但是这是在本地的,我往公司服务器上传代码后后台就不能正常跑起来了,因为node_modules不受版本控制的,而正式服务器上又不会自动安装这些模块.所以这个应该怎么解决呢??------ios学前端的小白- -!
ringa_lee2017-04-17 15:17:28
node_modules are only used locally. Some modules will install different modules according to the system version and nodejs version, so what you have to do is to move the node_modules folder out of the project directory, and then upload the project directory (in order to improve the upload speed, upload it anyway Delete it even if you go up), and then npm install again on the server
天蓬老师2017-04-17 15:17:28
npm uses package.json
this file to declare project dependencies.
1. Assume that the project already has package.json
this file
Then, when installing simditor
, you can add --save
to automatically add simditor
to the package.json
file
npm install simditor --save
Then, you will find that the package.json
field content of dependencies
has an additional dependency.
When you get to the official server, run npm install
in the project path and the relevant dependencies will be downloaded.
2. Assuming that the package.json
file does not exist yet, then run the following command to create one. After creation, refer to the previous steps
npm init -f
Note: Do not include node_modules
in version control unless necessary.