记录一次npm install报错

报错信息:

gyp ERR! stack Error: Command failed: C:\Users\liufei\AppData\Local\Programs\Python\Python37\python.EXE -c import sys; print “%s.%s.%s” %

完整报错:

F:\webstorm\cloud-desktop> npm install
npm WARN deprecated fsevents@1.2.13: fsevents 1 will break on node v14+ and could be using insecure binaries. Upgrade to fsevents 2.

> xxhash-addon@1.4.0 install F:\webstorm\cloud-desktop\node_modules\xxhash-addon
> node-gyp rebuild --ensure


F:\webstorm\cloud-desktop\node_modules\xxhash-addon>if not defined npm_config_node_gyp (node "E:\node\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild --ensure )  else (node "E:\node\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js" rebuild --ensure )
gyp ERR! configure error
gyp ERR! stack Error: Command failed: C:\Users\liufei\AppData\Local\Programs\Python\Python37\python.EXE -c import sys; print "%s.%s.%s" % sys.version_info[:3];
gyp ERR! stack   File "<string>", line 1
gyp ERR! stack     import sys; print "%s.%s.%s" % sys.version_info[:3];
gyp ERR! stack                                ^
gyp ERR! stack SyntaxError: invalid syntax
gyp ERR! stack
gyp ERR! stack     at ChildProcess.exithandler (child_process.js:294:12)
gyp ERR! stack     at ChildProcess.emit (events.js:198:13)
gyp ERR! stack     at maybeClose (internal/child_process.js:982:16)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:259:5)
gyp ERR! System Windows_NT 10.0.17763
gyp ERR! command "E:\\node\\node.exe" "E:\\node\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild" "--ensure"
gyp ERR! cwd F:\webstorm\cloud-desktop\node_modules\xxhash-addon
gyp ERR! node -v v10.16.0
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok
npm WARN @babel/plugin-syntax-jsx@7.14.5 requires a peer of @babel/core@^7.0.0-0 but none is installed. You must install peer dependencies yourself.
npm WARN @vue/babel-plugin-transform-vue-jsx@1.2.1 requires a peer of @babel/core@^7.0.0-0 but none is installed. You must install peer dependencies yourself.
npm WARN cloud-desktop@1.0.0 No repository field.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.13 (node_modules\webpack-dev-server\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.13: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@2.3.2 (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.3.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.13 (node_modules\watchpack-chokidar2\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.13: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! xxhash-addon@1.4.0 install: `node-gyp rebuild --ensure`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the xxhash-addon@1.4.0 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\liufei\AppData\Roaming\npm-cache\_logs\2021-06-10T02_12_29_752Z-debug.log

解决办法

步骤一

npm install --global --production windows-build-tools
npm install -g node-gyp

如果执行第一句执行没有成功,例如我的:
执行失败
这里卡在安装python了,直接终止执行步骤二即可。

步骤二

上面步骤一如果没有安装好python2.7,则安装下

npm install --python=python2.7

npm config set python python2.7

步骤三

npm install

npm run dev

启动成功!!

参考
https://blog.csdn.net/qfxlw/article/details/85331869

### 解决 `npm install` 出现 "up to date" 报错问题 当运行 `npm install` 命令时遇到 "up to date" 的提示并不一定表示错误,而是 npm 认为当前项目依赖已经是最新的版本[^1]。然而,在某些情况下这可能不是预期的行为。 #### 可能的原因分析 1. **缓存问题** 如果本地缓存损坏或过期,可能会导致包管理器无法正确识别最新的依赖项。 2. **锁定文件冲突** 存在 `package-lock.json` 或者 `yarn.lock` 文件的情况下,如果这些文件中的版本号与期望的不同,则可能导致更新失败。 3. **网络连接不稳定** 不稳定的互联网连接也可能影响到下载远程资源的能力,进而引发此类警告。 #### 推荐的解决方案 ##### 清理 NPM 缓存 清理全局和项目的 npm 缓存可以有效解决由于缓存引起的各种奇怪行为: ```bash npm cache clean --force ``` ##### 删除 node_modules 和 package-lock.json/yarn.lock 并重新安装 移除现有的模块目录以及锁定文件后再尝试重新安装所有依赖: ```bash rm -rf node_modules package-lock.json yarn.lock npm install ``` ##### 使用特定标志强制升级 通过指定 `-g` 参数来全局安装工具类库(如 Vue CLI),对于其他类型的包可以通过添加 `--legacy-peer-deps` 来忽略 peerDependencies 警告并继续安装过程;也可以利用 `--save-exact` 将确切版本记录下来防止不必要的变动: ```bash npm install --legacy-peer-deps # 或者 npm install --save-exact ``` ##### 更新 NPM 版本 有时旧版本的 npm 自身就存在问题,因此保持其处于最新状态也是很重要的一步操作: ```bash npm install -g npm@latest ``` 以上方法应该能够帮助处理大多数关于 `npm install` 执行过程中出现 “up to date” 提示的情况。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值