gpt4 book ai didi

node.js - 使用 npm 构建失败

转载 作者:行者123 更新时间:2023-12-04 19:41:54 24 4
gpt4 key购买 nike

使用 nodejs 构建项目失败

操作系统是 CentOS 7.4.1708 X64

下载并解压node-v8.12.0-linux-x64.tar.gz
然后,将目录添加到 PATH

[root in ~]# node -v
v8.12.0
[root in ~]# npm -v
6.4.1

我的项目目录是:
[root in /web/www/camp_admin_test/trunk/camp-vue]# ls -l
total 604
drwxr-xr-x 2 root root 4096 Jul 26 17:43 build
drwxr-xr-x 2 root root 4096 Jul 26 17:43 config
drwxr-xr-x 3 root root 4096 Jul 26 17:43 dist
-rw-r--r-- 1 root root 276 Jul 26 17:43 index.html
drwxr-xr-x 998 root root 36864 Jul 26 17:53 node_modules
-rw-r--r-- 1 root root 2435 Jul 26 17:53 package.json
-rw-r--r-- 1 root root 537923 Jul 26 17:53 package-lock.json
-rw-r--r-- 1 root root 557 Jul 26 17:43 README.md
drwxr-xr-x 8 root root 4096 Jul 26 17:43 src
drwxr-xr-x 2 root root 4096 Jul 26 17:43 static
drwxr-xr-x 4 root root 4096 Jul 26 17:43 test

在此目录中,运行 npm 运行开发
失败,输出为:
 ERROR  Failed to compile with 13 errors                                                                     18:13:35

This dependency was not found:

* @/pages/common/Nodata in ./node_modules/babel-loader/lib!./node_modules/vue-loader/lib/selector.js?type=script&index=0!./src/pages/MicLesson/LessionType.vue, ./node_modules/babel-loader/lib!./node_modules/vue-loader/lib/selector.js?type=script&index=0!./src/pages/MicLesson/Lessions.vue and 11 others

To install it, you can run: npm install --save @/pages/common/Nodata

我听从它的建议:

npm install --save @/pages/common/Nodata



得到这个:
[root in /web/www/camp_admin_test/trunk/camp-vue]# npm install --save @/pages/common/Nodata
npm ERR! code ENOLOCAL
npm ERR! Could not install from "@/pages/common/Nodata" as it does not contain a package.json file.

npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2019-07-26T10_14_59_597Z-debug.log

日志文件是:
[root in /web/www/camp_admin_test/trunk/camp-vue]# cat /root/.npm/_logs/2019-07-26T10_14_59_597Z-deb
0 info it worked if it ends with ok
1 verbose cli [ '/usr/local/node-v8.12.0-linux-x64/bin/node',
1 verbose cli '/usr/local/node-v8.12.0-linux-x64/bin/npm',
1 verbose cli 'install',
1 verbose cli '--save',
1 verbose cli '@/pages/common/Nodata' ]
2 info using npm@6.4.1
3 info using node@v8.12.0
4 verbose npm-session ff98e06075a6fb08
5 silly install loadCurrentTree
6 silly install readLocalPackageData
7 silly fetchPackageMetaData error for file:@/pages/common/Nodata Could not install from "@/pages/common/Nodata" as it does not contain a package.json file.
8 timing stage:rollbackFailedOptional Completed in 2ms
9 timing stage:runTopLevelLifecycles Completed in 3929ms
10 verbose stack Error: ENOENT: no such file or directory, open '/web/www/camp_admin_test/trunk/camp-vue/@/pages/common/Nodata/package.json'
11 verbose cwd /web/www/camp_admin_test/trunk/camp-vue
12 verbose Linux 3.10.0-693.2.2.el7.x86_64
13 verbose argv "/usr/local/node-v8.12.0-linux-x64/bin/node" "/usr/local/node-v8.12.0-linux-x64/bin/npm" "install" "--save" "@/pages/common/Nodata"
14 verbose node v8.12.0
15 verbose npm v6.4.1
16 error code ENOLOCAL
17 error Could not install from "@/pages/common/Nodata" as it does not contain a package.json file.
18 verbose exit [ 1, true ]

有什么帮助吗?
谢谢你。

最佳答案

npm-check-updates 将你的 package.json 依赖升级到最新版本,忽略指定的版本。

运行 npm install 以更新已安装的包和 package-lock.json。

npm i -g npm-check-updates
npm-check-updates -u
npm install --no-bin-links
npm update
npm run dev

有关更多信息,您可以引用 npm 文档:

https://docs.npmjs.com/cli/update.html

关于node.js - 使用 npm 构建失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57218013/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com