How to install NodeJS project locally without internet connection?

前端 未结 2 1807
庸人自扰
庸人自扰 2020-12-02 14:02

I have a project which I will have to deploy to client Windows systems where it will not be possible to connect to internet. I currently have a folder in D:\\NODE which cont

相关标签:
2条回答
  • 2020-12-02 14:20

    1 - In system with internet access install module with this command:

    npm install [module name]
    

    2 - go to %userprofile%\AppData\Roaming\npm\node_modules[module name]\ (e.g C:\Users\janson\AppData\Roaming\npm\node_modules\grunt-cli)
    3 - run npm pack
    4 - this should result in a [module name]-x.y.z.tgz file
    5 - run npm i -g [module name]-x.y.z.tgz in offline system

    0 讨论(0)
  • 2020-12-02 14:23

    You can install packages on a system without internet connection by packing them using built-in functionality in npm. This way, the node modules will be installed properly.

    1. Create a package.json.
    2. In your package.json, list all the modules you need under bundledDependencies (docs on npm).
    3. Run npm install to install your node files before packing.
    4. Create a tarball with npm pack.
    5. Copy the tarball over to the machine without internet connection.
    6. Install the modules with npm install <filename>.

    Update

    Regarding your comments, it looks like your globally installed node modules isn't found.

    Try using the npm link command (docs on npm link):

    1. cd yourAppFolder
    2. npm link node-windows
    0 讨论(0)
提交回复
热议问题