首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >无法运行next.js应用程序。它显示了奇怪的错误

无法运行next.js应用程序。它显示了奇怪的错误
EN

Stack Overflow用户
提问于 2021-09-24 08:55:22
回答 1查看 1.1K关注 0票数 0

所以这是一个客户的项目。他把他的next.js文件给了我。因此,我下载了这些文件,然后清除缓存、删除的节点模块和package-lock.json文件,然后安装所有依赖项。但是现在,当我尝试启动npm时,出现了这个奇怪的错误。

代码语言:javascript
复制
info  - Using webpack 5. Reason: Enabled by default https://nextjs.org/docs/messages/webpack5
info  - Checking validity of types
warn  - No ESLint configuration detected. Run next lint to begin setup
info  - Creating an optimized production build  
info  - Compiled successfully

> Build error occurred
Error: Only absolute URLs are supported
    at new ApolloError (C:\Users\User\Desktop\buybeauty-main\node_modules\@apollo\client\errors\errors.cjs.js:34:28)
    at C:\Users\User\Desktop\buybeauty-main\node_modules\@apollo\client\core\core.cjs.js:1593:19
    at both (C:\Users\User\Desktop\buybeauty-main\node_modules\@apollo\client\utilities\utilities.cjs.js:981:53)
    at C:\Users\User\Desktop\buybeauty-main\node_modules\@apollo\client\utilities\utilities.cjs.js:974:72    
    at new Promise (<anonymous>)
    at Object.then (C:\Users\User\Desktop\buybeauty-main\node_modules\@apollo\client\utilities\utilities.cjs.js:974:24)
    at Object.error (C:\Users\User\Desktop\buybeauty-main\node_modules\@apollo\client\utilities\utilities.cjs.js:982:49)
    at notifySubscription (C:\Users\User\Desktop\buybeauty-main\node_modules\zen-observable\lib\Observable.js:140:18)
    at onNotify (C:\Users\User\Desktop\buybeauty-main\node_modules\zen-observable\lib\Observable.js:179:3)   
    at SubscriptionObserver.error (C:\Users\User\Desktop\buybeauty-main\node_modules\zen-observable\lib\Observable.js:240:7) {
  type: 'ApolloError',
  graphQLErrors: [],
  clientErrors: [],
  networkError: {}
}
info  - Collecting page data .npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! nuskin@0.1.0 build: `next build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the nuskin@0.1.0 build 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\User\AppData\Roaming\npm-cache\_logs\2021-09-24T10_55_42_879Z-debug.log

这是我的日志

代码语言:javascript
复制
0 info it worked if it ends with ok
1 verbose cli [
1 verbose cli   'C:\\Program Files\\nodejs\\node.exe',
1 verbose cli   'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli   'start'
1 verbose cli ]
2 info using npm@6.14.11
3 info using node@v14.16.0
4 verbose run-script [ 'prestart', 'start', 'poststart' ]
5 info lifecycle nuskin@0.1.0~prestart: nuskin@0.1.0
6 info lifecycle nuskin@0.1.0~start: nuskin@0.1.0
7 verbose lifecycle nuskin@0.1.0~start: unsafe-perm in lifecycle true
8 verbose lifecycle nuskin@0.1.0~start: PATH: C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin;C:\Users\User\Desktop\buybeauty-main\node_modules\.bin;C:\ProgramData\Oracle\Java\javapath;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR;C:\Users\User\AppData\Local\Programs\Python\Python38-32\Scripts;C:\Users\User\AppData\Roaming\Python\Python38;C:\Program Files\Git\cmd;C:\Program Files (x86)\Wolfram Research\WolframScript\;C:\Program Files\Wolfram Research\WolframScript\;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\Program Files\nodejs\;C:\Program Files\nodejs\node_modules\npm\bin;C:\Users\User\AppData\Local\Programs\Microsoft VS Code\bin;C:\Users\User\AppData\Roaming\npm\;
9 verbose lifecycle nuskin@0.1.0~start: CWD: C:\Users\User\Desktop\buybeauty-main
10 silly lifecycle nuskin@0.1.0~start: Args: [ '/d /s /c', 'next start' ]
11 silly lifecycle nuskin@0.1.0~start: Returned: code: 1  signal: null
12 info lifecycle nuskin@0.1.0~start: Failed to exec start script
13 verbose stack Error: nuskin@0.1.0 start: `next start`
13 verbose stack Exit status 1
13 verbose stack     at EventEmitter.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\index.js:332:16)
13 verbose stack     at EventEmitter.emit (events.js:315:20)
13 verbose stack     at ChildProcess.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\lib\spawn.js:55:14)
13 verbose stack     at ChildProcess.emit (events.js:315:20)
13 verbose stack     at maybeClose (internal/child_process.js:1048:16)
13 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:288:5)
14 verbose pkgid nuskin@0.1.0
15 verbose cwd C:\Users\User\Desktop\buybeauty-main
16 verbose Windows_NT 10.0.19042
17 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "start"
18 verbose node v14.16.0
19 verbose npm  v6.14.11
20 error code ELIFECYCLE
21 error errno 1
22 error nuskin@0.1.0 start: `next start`
22 error Exit status 1
23 error Failed at the nuskin@0.1.0 start script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]

这是我的package.json文件

代码语言:javascript
复制
{
  "name": "nuskin",
  "version": "0.1.0",
  "private": true,
  "scripts": {
    "dev": "next dev",
    "build": "next build",
    "start": "next start",
    "svg": "svgr -d src/components/icons src/components/icons/svgs"
  },
  "dependencies": {
    "@apollo/client": "^3.3.16",
    "@stripe/stripe-js": "^1.14.0",
    "@svgr/cli": "^5.5.0",
    "@woocommerce/woocommerce-rest-api": "^1.0.1",
    "axios": "^0.21.1",
    "body-scroll-lock": "^4.0.0-beta.0",
    "classnames": "^2.3.1",
    "firebase": "^9.0.2",
    "graphql": "^15.4.0",
    "lodash": "^4.17.20",
    "micro": "^9.3.4",
    "next": "^11.1.2",
    "next-stripe": "^1.0.0-beta.9",
    "node-fetch": "^2.6.1",
    "nprogress": "^0.2.0",
    "prop-types": "^15.7.2",
    "react": "^17.0.1",
    "react-dom": "17.0.1",
    "sass": "^1.29.0",
    "stripe": "^8.148.0",
    "uuid": "^8.3.1",
    "validator": "^13.1.17"
  },
  "devDependencies": {
    "autoprefixer": "^10.3.4",
    "install": "^0.13.0",
    "postcss": "^8.3.6",
    "postcss-flexbugs-fixes": "^5.0.1",
    "postcss-import": "^13.0.0",
    "postcss-preset-env": "^6.7.0",
    "precss": "^4.0.0",
    "tailwindcss": "^2.2.11"
  }
}
EN

回答 1

Stack Overflow用户

发布于 2021-09-24 09:07:25

为什么要删除package-lock.json?你能分享一下日志吗?

可能没有包含下一个配置文件,并且某些值(例如环境变量)对于您的项目是不可读的。因此,可能在项目中的某个位置,URL接口被初始化为空值:at new URL (internal/url.js:335:5)

票数 -1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/69312219

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档