'npm install

编程入门 行业动态 更新时间:2024-10-28 08:23:30
本文介绍了'npm install -g' 到底做了什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我想使用 sinopia 设置一个私有的 npm 注册表,我执行了 npm install -g sinopia,但是出现了一些错误信息:

I want to set up a private npm registry using sinopia and I executed npm install -g sinopia, but some error message occurred:

> crypt3@0.1.8 install /usr/local/lib/node_modules/sinopia/node_modules/crypt3 > node-gyp rebuild gyp WARN EACCES user "root" does not have permission to access the dev dir "/root/.node-gyp/4.2.3" gyp WARN EACCES attempting to reinstall using temporary dev dir "/usr/local/lib/node_modules/sinopia/node_modules/crypt3/.node-gyp" make: Entering directory `/usr/local/lib/node_modules/sinopia/node_modules/crypt3/build' CXX(target) Release/obj.target/crypt3/crypt3.o In file included from ../crypt3.cc:7:0: ../node_modules/nan/nan.h:261:25: error: redefinition of âtemplate<class T> v8::Local<T> _NanEnsureLocal(v8::Local<T>)â NAN_INLINE v8::Local<T> _NanEnsureLocal(v8::Local<T> val) { ^ ../node_modules/nan/nan.h:256:25: error: âtemplate<class T> v8::Local<T> _NanEnsureLocal(v8::Handle<T>)â previously declared here NAN_INLINE v8::Local<T> _NanEnsureLocal(v8::Handle<T> val) { ^ ../node_modules/nan/nan.h:661:13: error: ânode::smallocâ has not been declared , node::smalloc::FreeCallback callback ^

我可以看到与C或C++相关的.h文件;怎么会这样?我在 sinopia 中发现的所有内容都与 JavaScript 相关.

I can see the .h files which relate to C or C++; how come this happens? All the stuff I found within sinopia is about JavaScript.

npm install 有什么作用?在我看来,它应该只启动一些下载过程.

What does npm install do? In my opinion, it should only initiate some download process.

推荐答案

npm install 或 npm install -g 将

  • 下载您使用参数指定的 npm 包,或在您的 package.json 文件中,连同它的依赖项(来自您定义的 npm 存储库主机)一起下载到 node_modules 文件夹中.(或使用它的现有本地副本.参见 shrink-wrapping)

    为自身和每个依赖项运行 pre-install、install 和 post-install 脚本.请参阅生命周期脚本

    Run the pre-install, install and post-install scripts for itself and each dependencies. See Lifecycle Scripts

    -g 指令告诉 npm 将包安装到全局共享的 node_modules 文件夹中(通常是 node 所在的位置).这也将允许您从命令行访问模块,因为 bin 被符号链接到 PATH 文件夹(通常是 usr/local/bin).检查此链接

    The -g directive tells npm to install the package in the global shared node_modules folder (usually where node is). This will also allow you to access the module from the command-line, as the bin is symlinked into a PATH folder (usually usr/local/bin). Check this link

    在 sinopia 的情况下,他们没有标准的 package.json 文件,他们有一个 package.yaml 文件.检查 yamp 插件.

    In the case of sinopia, they do not have a standard package.json file, they have a package.yaml file. Check the yamp plugin.

    如果你检查他们的预发布脚本,它包含

    If you check their pre-publish script, it contains

    prepublish: js-yaml package.yaml > package.json

    将他们的 package.yaml 转换为 package.json.在他们的 package.json 中,他们依赖于 crypt3 包.

    Which converts their package.yaml into package.json. In their package.json, they have a dependency on the crypt3 package.

    如果是 crypt3(sinopia 依赖之一),请检查 package.json .它包含

    In the case of crypt3 (one of sinopia dependencies), check the package.json . It contains

    "scripts": { "test": "node test/test.js", "install": "node-gyp rebuild" },

    所以,当安装了sinopia 时,它也会下载并安装它的所有依赖项.安装 crypt3 后,将运行node-gyp rebuild",这就是为什么您会在控制台中看到本机 c/c++ 编译输出.

    So, when sinopia is npm installed, it will download and install all it's dependencies as well. When crypt3 is installed, the "node-gyp rebuild" will be run, that's why you are seeing native c / c++ compile outputs in your console.

    你可以自己试试

    npm install -g node-gyp && node-gyp rebuild

    在控制台中

  • 更多推荐

    'npm install

    本文发布于:2023-06-08 14:28:14,感谢您对本站的认可!
    本文链接:https://www.elefans.com/category/jswz/34/583068.html
    版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
    本文标签:npm   install

    发布评论

    评论列表 (有 0 条评论)
    草根站长

    >www.elefans.com

    编程频道|电子爱好者 - 技术资讯及电子产品介绍!