linux:ubuntu21.04:npm安装@vue/cli时报错(@vue/cli 4.5.13/npm 7.21.0/node 14.17.1)
一,第一次安装时报错:
root@lhdpc:/usr/local/source# npm install -g @vue/cli npm WARN deprecated @hapi/topo@3.1.6: This version has been deprecated and is no longer supported or maintained npm WARN deprecated @hapi/bourne@1.3.2: This version has been deprecated and is no longer supported or maintained npm WARN deprecated urix@0.1.0: Please see https://github.com/lydell/urix#deprecated npm WARN deprecated har-validator@5.1.5: this library is no longer supported npm WARN deprecated apollo-tracing@0.15.0: The `apollo-tracing` package is no longer part of Apollo Server 3. See https://www.apollographql.com/docs/apollo-server/migration/#tracing for details npm WARN deprecated graphql-extensions@0.15.0: The `graphql-extensions` API has been removed from Apollo Server 3. Use the plugin API instead: https://www.apollographql.com/docs/apollo-server/integrations/plugins/ npm WARN deprecated @hapi/address@2.1.4: Moved to 'npm install @sideway/address' npm WARN deprecated @hapi/hoek@8.5.1: This version has been deprecated and is no longer supported or maintained npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142 npm WARN deprecated @hapi/joi@15.1.1: Switch to 'npm install joi' npm WARN deprecated graphql-tools@4.0.8: This package has been deprecated and now it only exports makeExecutableSchema.\nAnd it will no longer receive updates.\nWe recommend you to migrate to scoped packages such as @graphql-tools/schema, @graphql-tools/utils and etc.\nCheck out https://www.graphql-tools.com to learn what package you should use instead npm ERR! code 1 npm ERR! path /usr/local/soft/node-v14.17.1-linux-x64/lib/node_modules/@vue/cli/node_modules/utf-8-validate npm ERR! command failed npm ERR! command sh -c node-gyp rebuild npm ERR! gyp info it worked if it ends with ok npm ERR! gyp info using node-gyp@7.1.2 npm ERR! gyp info using node@14.17.1 | linux | x64 npm ERR! gyp info find Python using Python version 3.9.5 found at "/usr/bin/python3" npm ERR! gyp WARN EACCES current user does not have permission to access the dev dir "/root/.cache/node-gyp/14.17.1" npm ERR! gyp WARN EACCES attempting to reinstall using temporary dev dir "/tmp/.node-gyp" npm ERR! gyp info spawn /usr/bin/python3 npm ERR! gyp info spawn args [ npm ERR! gyp info spawn args '/usr/local/soft/node-v14.17.1-linux-x64/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py', npm ERR! gyp info spawn args 'binding.gyp', npm ERR! gyp info spawn args '-f', npm ERR! gyp info spawn args 'make', npm ERR! gyp info spawn args '-I', npm ERR! gyp info spawn args '/usr/local/soft/node-v14.17.1-linux-x64/lib/node_modules/@vue/cli/node_modules/utf-8-validate/build/config.gypi', npm ERR! gyp info spawn args '-I', npm ERR! gyp info spawn args '/usr/local/soft/node-v14.17.1-linux-x64/lib/node_modules/npm/node_modules/node-gyp/addon.gypi', npm ERR! gyp info spawn args '-I', npm ERR! gyp info spawn args '/tmp/.node-gyp/14.17.1/include/node/common.gypi', npm ERR! gyp info spawn args '-Dlibrary=shared_library', npm ERR! gyp info spawn args '-Dvisibility=default', npm ERR! gyp info spawn args '-Dnode_root_dir=/tmp/.node-gyp/14.17.1', npm ERR! gyp info spawn args '-Dnode_gyp_dir=/usr/local/soft/node-v14.17.1-linux-x64/lib/node_modules/npm/node_modules/node-gyp', npm ERR! gyp info spawn args '-Dnode_lib_file=/tmp/.node-gyp/14.17.1/<(target_arch)/node.lib', npm ERR! gyp info spawn args '-Dmodule_root_dir=/usr/local/soft/node-v14.17.1-linux-x64/lib/node_modules/@vue/cli/node_modules/utf-8-validate', npm ERR! gyp info spawn args '-Dnode_engine=v8', npm ERR! gyp info spawn args '--depth=.', npm ERR! gyp info spawn args '--no-parallel', npm ERR! gyp info spawn args '--generator-output', npm ERR! gyp info spawn args 'build', npm ERR! gyp info spawn args '-Goutput_dir=.' npm ERR! gyp info spawn args ] npm ERR! gyp ERR! build error npm ERR! gyp ERR! stack Error: not found: make npm ERR! gyp ERR! stack at getNotFoundError (/usr/local/soft/node-v14.17.1-linux-x64/lib/node_modules/npm/node_modules/which/which.js:10:17) npm ERR! gyp ERR! stack at /usr/local/soft/node-v14.17.1-linux-x64/lib/node_modules/npm/node_modules/which/which.js:57:18 npm ERR! gyp ERR! stack at new Promise (<anonymous>) npm ERR! gyp ERR! stack at step (/usr/local/soft/node-v14.17.1-linux-x64/lib/node_modules/npm/node_modules/which/which.js:54:21) npm ERR! gyp ERR! stack at /usr/local/soft/node-v14.17.1-linux-x64/lib/node_modules/npm/node_modules/which/which.js:71:22 npm ERR! gyp ERR! stack at new Promise (<anonymous>) npm ERR! gyp ERR! stack at subStep (/usr/local/soft/node-v14.17.1-linux-x64/lib/node_modules/npm/node_modules/which/which.js:69:33) npm ERR! gyp ERR! stack at /usr/local/soft/node-v14.17.1-linux-x64/lib/node_modules/npm/node_modules/which/which.js:80:22 npm ERR! gyp ERR! stack at /usr/local/soft/node-v14.17.1-linux-x64/lib/node_modules/npm/node_modules/isexe/index.js:42:5 npm ERR! gyp ERR! stack at /usr/local/soft/node-v14.17.1-linux-x64/lib/node_modules/npm/node_modules/isexe/mode.js:8:5 npm ERR! gyp ERR! System Linux 5.11.0-31-generic npm ERR! gyp ERR! command "/usr/local/soft/node-v14.17.1-linux-x64/bin/node" "/usr/local/soft/node-v14.17.1-linux-x64/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild" npm ERR! gyp ERR! cwd /usr/local/soft/node-v14.17.1-linux-x64/lib/node_modules/@vue/cli/node_modules/utf-8-validate npm ERR! gyp ERR! node -v v14.17.1 npm ERR! gyp ERR! node-gyp -v v7.1.2 npm ERR! gyp ERR! not ok npm ERR! A complete log of this run can be found in: npm ERR! /root/.npm/_logs/2021-08-23T03_25_56_917Z-debug.log
截图:
解决:安装make
root@lhdpc:/usr/local/source# whereis make make: root@lhdpc:/usr/local/source# apt-get install make 正在读取软件包列表... 完成 正在分析软件包的依赖关系树... 完成 正在读取状态信息... 完成 下列软件包是自动安装的并且现在不需要了: libllvm11 使用'apt autoremove'来卸载它(它们)。 建议安装: make-doc 下列【新】软件包将被安装: make 升级了 0 个软件包,新安装了 1 个软件包,要卸载 0 个软件包,有 0 个软件包未被升级。 需要下载 167 kB 的归档。 解压缩后会消耗 414 kB 的额外空间。 获取:1 http://cn.archive.ubuntu.com/ubuntu hirsute/main amd64 make amd64 4.3-4ubuntu1 [167 kB] 已下载 167 kB,耗时 2秒 (98.6 kB/s) 正在选中未选择的软件包 make。 (正在读取数据库 ... 系统当前共安装有 201167 个文件和目录。) 准备解压 .../make_4.3-4ubuntu1_amd64.deb ... 正在解压 make (4.3-4ubuntu1) ... 正在设置 make (4.3-4ubuntu1) ... 正在处理用于 man-db (2.9.4-2) 的触发器 …
查看效果
root@lhdpc:/usr/local/source# whereis make make: /usr/bin/make /usr/share/man/man1/make.1.gz
说明:刘宏缔的架构森林是一个专注架构的博客,
网站:https://blog.imgtouch.com
本文: https://blog.imgtouch.com/index.php/2023/05/27/linux-ubuntu21-04-npm-an-zhuang-vue-cli-shi-bao-cuo-vue-cli/
对应的源码可以访问这里获取: https://github.com/liuhongdi/
说明:作者:刘宏缔 邮箱: 371125307@qq.com
二,第二次安装时报错:
root@lhdpc:/usr/local/source# npm install -g @vue/cli npm WARN deprecated @hapi/topo@3.1.6: This version has been deprecated and is no longer supported or maintained npm WARN deprecated @hapi/bourne@1.3.2: This version has been deprecated and is no longer supported or maintained npm WARN deprecated urix@0.1.0: Please see https://github.com/lydell/urix#deprecated npm WARN deprecated har-validator@5.1.5: this library is no longer supported npm WARN deprecated apollo-tracing@0.15.0: The `apollo-tracing` package is no longer part of Apollo Server 3. See https://www.apollographql.com/docs/apollo-server/migration/#tracing for details npm WARN deprecated graphql-extensions@0.15.0: The `graphql-extensions` API has been removed from Apollo Server 3. Use the plugin API instead: https://www.apollographql.com/docs/apollo-server/integrations/plugins/ npm WARN deprecated @hapi/address@2.1.4: Moved to 'npm install @sideway/address' npm WARN deprecated @hapi/hoek@8.5.1: This version has been deprecated and is no longer supported or maintained npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142 npm WARN deprecated @hapi/joi@15.1.1: Switch to 'npm install joi' npm WARN deprecated graphql-tools@4.0.8: This package has been deprecated and now it only exports makeExecutableSchema.\nAnd it will no longer receive updates.\nWe recommend you to migrate to scoped packages such as @graphql-tools/schema, @graphql-tools/utils and etc.\nCheck out https://www.graphql-tools.com to learn what package you should use instead npm ERR! code 1 npm ERR! path /usr/local/soft/node-v14.17.1-linux-x64/lib/node_modules/@vue/cli/node_modules/bufferutil npm ERR! command failed npm ERR! command sh -c node-gyp rebuild npm ERR! make: 进入目录“/usr/local/soft/node-v14.17.1-linux-x64/lib/node_modules/@vue/cli/node_modules/bufferutil/build” npm ERR! CC(target) Release/obj.target/bufferutil/src/bufferutil.o npm ERR! make: 离开目录“/usr/local/soft/node-v14.17.1-linux-x64/lib/node_modules/@vue/cli/node_modules/bufferutil/build” npm ERR! gyp info it worked if it ends with ok npm ERR! gyp info using node-gyp@7.1.2 npm ERR! gyp info using node@14.17.1 | linux | x64 npm ERR! gyp info find Python using Python version 3.9.5 found at "/usr/bin/python3" npm ERR! gyp WARN EACCES current user does not have permission to access the dev dir "/root/.cache/node-gyp/14.17.1" npm ERR! gyp WARN EACCES attempting to reinstall using temporary dev dir "/tmp/.node-gyp" npm ERR! gyp info spawn /usr/bin/python3 npm ERR! gyp info spawn args [ npm ERR! gyp info spawn args '/usr/local/soft/node-v14.17.1-linux-x64/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py', npm ERR! gyp info spawn args 'binding.gyp', npm ERR! gyp info spawn args '-f', npm ERR! gyp info spawn args 'make', npm ERR! gyp info spawn args '-I', npm ERR! gyp info spawn args '/usr/local/soft/node-v14.17.1-linux-x64/lib/node_modules/@vue/cli/node_modules/bufferutil/build/config.gypi', npm ERR! gyp info spawn args '-I', npm ERR! gyp info spawn args '/usr/local/soft/node-v14.17.1-linux-x64/lib/node_modules/npm/node_modules/node-gyp/addon.gypi', npm ERR! gyp info spawn args '-I', npm ERR! gyp info spawn args '/tmp/.node-gyp/14.17.1/include/node/common.gypi', npm ERR! gyp info spawn args '-Dlibrary=shared_library', npm ERR! gyp info spawn args '-Dvisibility=default', npm ERR! gyp info spawn args '-Dnode_root_dir=/tmp/.node-gyp/14.17.1', npm ERR! gyp info spawn args '-Dnode_gyp_dir=/usr/local/soft/node-v14.17.1-linux-x64/lib/node_modules/npm/node_modules/node-gyp', npm ERR! gyp info spawn args '-Dnode_lib_file=/tmp/.node-gyp/14.17.1/<(target_arch)/node.lib', npm ERR! gyp info spawn args '-Dmodule_root_dir=/usr/local/soft/node-v14.17.1-linux-x64/lib/node_modules/@vue/cli/node_modules/bufferutil', npm ERR! gyp info spawn args '-Dnode_engine=v8', npm ERR! gyp info spawn args '--depth=.', npm ERR! gyp info spawn args '--no-parallel', npm ERR! gyp info spawn args '--generator-output', npm ERR! gyp info spawn args 'build', npm ERR! gyp info spawn args '-Goutput_dir=.' npm ERR! gyp info spawn args ] npm ERR! gyp info spawn make npm ERR! gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ] npm ERR! make: cc: 没有那个文件或目录 npm ERR! make: *** [bufferutil.target.mk:111:Release/obj.target/bufferutil/src/bufferutil.o] 错误 127 npm ERR! gyp ERR! build error npm ERR! gyp ERR! stack Error: `make` failed with exit code: 2 npm ERR! gyp ERR! stack at ChildProcess.onExit (/usr/local/soft/node-v14.17.1-linux-x64/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:194:23) npm ERR! gyp ERR! stack at ChildProcess.emit (events.js:375:28) npm ERR! gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:277:12) npm ERR! gyp ERR! System Linux 5.11.0-31-generic npm ERR! gyp ERR! command "/usr/local/soft/node-v14.17.1-linux-x64/bin/node" "/usr/local/soft/node-v14.17.1-linux-x64/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild" npm ERR! gyp ERR! cwd /usr/local/soft/node-v14.17.1-linux-x64/lib/node_modules/@vue/cli/node_modules/bufferutil npm ERR! gyp ERR! node -v v14.17.1 npm ERR! gyp ERR! node-gyp -v v7.1.2 npm ERR! gyp ERR! not ok npm ERR! A complete log of this run can be found in: npm ERR! /root/.npm/_logs/2021-08-23T03_40_08_878Z-debug.log
截图:
解决:安装gcc
root@lhdpc:/usr/local/source# whereis cc cc: root@lhdpc:/usr/local/source# apt-get install gcc
安装完成后查看效果:
root@lhdpc:/usr/local/source# whereis cc cc: /usr/bin/cc /usr/share/man/man1/cc.1.gz
三,第三次安装报错:
root@lhdpc:/usr/local/source# npm install -g @vue/cli npm WARN deprecated @hapi/topo@3.1.6: This version has been deprecated and is no longer supported or maintained npm WARN deprecated @hapi/bourne@1.3.2: This version has been deprecated and is no longer supported or maintained npm WARN deprecated urix@0.1.0: Please see https://github.com/lydell/urix#deprecated npm WARN deprecated har-validator@5.1.5: this library is no longer supported npm WARN deprecated apollo-tracing@0.15.0: The `apollo-tracing` package is no longer part of Apollo Server 3. See https://www.apollographql.com/docs/apollo-server/migration/#tracing for details npm WARN deprecated graphql-extensions@0.15.0: The `graphql-extensions` API has been removed from Apollo Server 3. Use the plugin API instead: https://www.apollographql.com/docs/apollo-server/integrations/plugins/ npm WARN deprecated @hapi/address@2.1.4: Moved to 'npm install @sideway/address' npm WARN deprecated @hapi/hoek@8.5.1: This version has been deprecated and is no longer supported or maintained npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142 npm WARN deprecated @hapi/joi@15.1.1: Switch to 'npm install joi' npm WARN deprecated graphql-tools@4.0.8: This package has been deprecated and now it only exports makeExecutableSchema.\nAnd it will no longer receive updates.\nWe recommend you to migrate to scoped packages such as @graphql-tools/schema, @graphql-tools/utils and etc.\nCheck out https://www.graphql-tools.com to learn what package you should use instead npm ERR! code 1 npm ERR! path /usr/local/soft/node-v14.17.1-linux-x64/lib/node_modules/@vue/cli/node_modules/utf-8-validate npm ERR! command failed npm ERR! command sh -c node-gyp rebuild npm ERR! make: 进入目录“/usr/local/soft/node-v14.17.1-linux-x64/lib/node_modules/@vue/cli/node_modules/utf-8-validate/build” npm ERR! CC(target) Release/obj.target/validation/src/validation.o npm ERR! SOLINK_MODULE(target) Release/obj.target/validation.node npm ERR! make: 离开目录“/usr/local/soft/node-v14.17.1-linux-x64/lib/node_modules/@vue/cli/node_modules/utf-8-validate/build” npm ERR! gyp info it worked if it ends with ok npm ERR! gyp info using node-gyp@7.1.2 npm ERR! gyp info using node@14.17.1 | linux | x64 npm ERR! gyp info find Python using Python version 3.9.5 found at "/usr/bin/python3" npm ERR! gyp WARN EACCES current user does not have permission to access the dev dir "/root/.cache/node-gyp/14.17.1" npm ERR! gyp WARN EACCES attempting to reinstall using temporary dev dir "/tmp/.node-gyp" npm ERR! gyp info spawn /usr/bin/python3 npm ERR! gyp info spawn args [ npm ERR! gyp info spawn args '/usr/local/soft/node-v14.17.1-linux-x64/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py', npm ERR! gyp info spawn args 'binding.gyp', npm ERR! gyp info spawn args '-f', npm ERR! gyp info spawn args 'make', npm ERR! gyp info spawn args '-I', npm ERR! gyp info spawn args '/usr/local/soft/node-v14.17.1-linux-x64/lib/node_modules/@vue/cli/node_modules/utf-8-validate/build/config.gypi', npm ERR! gyp info spawn args '-I', npm ERR! gyp info spawn args '/usr/local/soft/node-v14.17.1-linux-x64/lib/node_modules/npm/node_modules/node-gyp/addon.gypi', npm ERR! gyp info spawn args '-I', npm ERR! gyp info spawn args '/tmp/.node-gyp/14.17.1/include/node/common.gypi', npm ERR! gyp info spawn args '-Dlibrary=shared_library', npm ERR! gyp info spawn args '-Dvisibility=default', npm ERR! gyp info spawn args '-Dnode_root_dir=/tmp/.node-gyp/14.17.1', npm ERR! gyp info spawn args '-Dnode_gyp_dir=/usr/local/soft/node-v14.17.1-linux-x64/lib/node_modules/npm/node_modules/node-gyp', npm ERR! gyp info spawn args '-Dnode_lib_file=/tmp/.node-gyp/14.17.1/<(target_arch)/node.lib', npm ERR! gyp info spawn args '-Dmodule_root_dir=/usr/local/soft/node-v14.17.1-linux-x64/lib/node_modules/@vue/cli/node_modules/utf-8-validate', npm ERR! gyp info spawn args '-Dnode_engine=v8', npm ERR! gyp info spawn args '--depth=.', npm ERR! gyp info spawn args '--no-parallel', npm ERR! gyp info spawn args '--generator-output', npm ERR! gyp info spawn args 'build', npm ERR! gyp info spawn args '-Goutput_dir=.' npm ERR! gyp info spawn args ] npm ERR! gyp info spawn make npm ERR! gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ] npm ERR! make: g++: 没有那个文件或目录 npm ERR! make: *** [validation.target.mk:139:Release/obj.target/validation.node] 错误 127 npm ERR! gyp ERR! build error npm ERR! gyp ERR! stack Error: `make` failed with exit code: 2 npm ERR! gyp ERR! stack at ChildProcess.onExit (/usr/local/soft/node-v14.17.1-linux-x64/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:194:23) npm ERR! gyp ERR! stack at ChildProcess.emit (events.js:375:28) npm ERR! gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:277:12) npm ERR! gyp ERR! System Linux 5.11.0-31-generic npm ERR! gyp ERR! command "/usr/local/soft/node-v14.17.1-linux-x64/bin/node" "/usr/local/soft/node-v14.17.1-linux-x64/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild" npm ERR! gyp ERR! cwd /usr/local/soft/node-v14.17.1-linux-x64/lib/node_modules/@vue/cli/node_modules/utf-8-validate npm ERR! gyp ERR! node -v v14.17.1 npm ERR! gyp ERR! node-gyp -v v7.1.2 npm ERR! gyp ERR! not ok npm ERR! A complete log of this run can be found in: npm ERR! /root/.npm/_logs/2021-08-23T03_48_41_338Z-debug.log
截图:
解决:安装g++:
root@lhdpc:/usr/local/source# apt-get install g++
查看安装后效果:
root@lhdpc:/usr/local/source# whereis g++ g++: /usr/bin/g++ /usr/share/man/man1/g++.1.gz
四,第四次安装成功:
创建符号链接
root@lhdpc:~# ln -s /usr/local/soft/node-v14.17.1-linux-x64/bin/vue /usr/local/bin/vue
查看文件
root@lhdpc:~# whereis vue vue: /usr/local/bin/vue
查看版本
root@lhdpc:/usr/local/source# vue -V @vue/cli 4.5.13
五,查看npm/node版本
root@lhdpc:/usr/local/source# npm -v 7.21.0 root@lhdpc:/usr/local/source# node -v v14.17.1
六,查看linux版本:
root@lhdpc:/usr/local/source# cat /etc/os-release NAME="Ubuntu" VERSION="21.04 (Hirsute Hippo)" ID=ubuntu ID_LIKE=debian PRETTY_NAME="Ubuntu 21.04" VERSION_ID="21.04" HOME_URL="https://www.ubuntu.com/" SUPPORT_URL="https://help.ubuntu.com/" BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/" PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy" VERSION_CODENAME=hirsute UBUNTU_CODENAME=hirsute