关于安装apollo-boost依赖时候报if not defined npm_config_node_gyp错误或者说找不到node-gyp.js文件处理

PS D:\E盘\Idea code\itcast-haoke-web> npm install apollo-boost react-apollo 1 graphql --save
npm WARN deprecated node-uuid@1.4.8: Use uuid module instead

> mdns2@2.1.4 install D:\E盘\Idea code\itcast-haoke-web\node_modules\mdns2
> node-gyp rebuild


D:\E盘\Idea code\itcast-haoke-web\node_modules\mdns2>if not defined npm_config_node_gyp (node "C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild )  else (node "node C:\Users\Sunny\AppData\Roaming\npm\node_modules\node-gyp\bin\node-gyp.js" rebuild )
internal/modules/cjs/loader.js:1023
  throw err;
  ^

Error: Cannot find module 'D:\E盘\Idea code\itcast-haoke-web\node_modules\mdns2\node C:\Users\Sunny\AppData\Roaming\npm\node_modules\node-gyp\bin\node-gyp.js'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:1020:15)
    at Function.Module._load (internal/modules/cjs/loader.js:890:27)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
    at internal/main/run_main_module.js:17:47 {
  code: 'MODULE_NOT_FOUND',
  requireStack: []
}

使用管理员身份进入命令行

  1. 先运行一下这个命令
    npm install --global --production windows-build-tools
    //安装的好像是一个python运行环境,中间有一个绿色的框框,结尾是python
    //提示+ windows-build-tools@5.2.2
    // updated 1 package in 107.732s说明安装成功

  2. 然后运行命令 ,好像是全局安装这个包
    npm install -g node-gyp
    //最后会提示一堆中文,=创建代码= === 生成代码=复制啥的=说明安装成功
    npm config set node_gyp "node C:\Users\Sunny\AppData\Roaming\npm\node_modules\node-gyp\bin\node-gyp.js"

  3. 然后把已经下载的node-modules文件删除,从新执行命令
    npm install //安装依赖就搞定了

将上面的操作完后,发现还是报错。后来发现运行的命令有问题。
npm install apollo-boost react-apollo 1 graphql --save
npm install apollo-boost react-apollo graphql --save
上面的命令多了个1.所以运行还是出错,删除1后就能正常运行。

  • 4
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值