最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How can I fix the following error: Data path "polyfills" must be string in my angular project? -

programmeradmin6浏览0评论

I am using NodeJS version 18. I am trying to deploy my Angular app to Firebase and/or run it successfully on my local, but I am unable to do so. [link to package.json and source code] -> .json

I have tried a lot of things but I am unable to figure it out. For example, in my angular.json file, I tried this:

and this

.

Then I tried running 'npm run build' I got the following error however.

Error: Module not found: Error: Can't resolve '/home/anshuman/Documents/repos/jovian-genai-hackathon/UI/zone.js' in '/home/anshuman/Documents/repos/jovian-genai-hackathon/UI'

I have seen these links, but they are asking to modify a file here called polyfills.ts which doesn't exist in my codebase. Angular2 Final Release - "Error: Angular requires Zone.js prolyfill"

And this describes the exact opposite of what my current problem is : Terminal error: Schema validation failed with the following errors: Data path "['polyfills']" should be array

I am using NodeJS version 18. I am trying to deploy my Angular app to Firebase and/or run it successfully on my local, but I am unable to do so. [link to package.json and source code] -> https://github./anshumankmr/jovian-genai-hackathon/blob/master/UI/package.json

I have tried a lot of things but I am unable to figure it out. For example, in my angular.json file, I tried this:

and this

.

Then I tried running 'npm run build' I got the following error however.

Error: Module not found: Error: Can't resolve '/home/anshuman/Documents/repos/jovian-genai-hackathon/UI/zone.js' in '/home/anshuman/Documents/repos/jovian-genai-hackathon/UI'

I have seen these links, but they are asking to modify a file here called polyfills.ts which doesn't exist in my codebase. Angular2 Final Release - "Error: Angular requires Zone.js prolyfill"

And this describes the exact opposite of what my current problem is : Terminal error: Schema validation failed with the following errors: Data path "['polyfills']" should be array

Share Improve this question edited Jun 28, 2023 at 6:10 Anshuman Kumar asked Jun 28, 2023 at 4:31 Anshuman KumarAnshuman Kumar 5771 gold badge8 silver badges28 bronze badges 4
  • Angular 14 isn't patible with Node18: more details here – Jacopo Sciampi Commented Jun 28, 2023 at 7:52
  • The guy who helped me develop this told me he was using Node 18 :| Will try with a lower version of node... thanks @JacopoSciampi – Anshuman Kumar Commented Jun 28, 2023 at 8:23
  • Getting the same error @JacopoSciampi. I used nvm to switch 14.15 version – Anshuman Kumar Commented Jun 29, 2023 at 4:08
  • >Error: Module not found: Error: Can't resolve '/home/anshuman/Documents/repos/jovian-genai-hackathon/UI/zone.js' in '/home/anshuman/Documents/repos/jovian-genai-hackathon/UI' – Anshuman Kumar Commented Jun 29, 2023 at 4:09
Add a ment  | 

1 Answer 1

Reset to default 8

I cloned the repo and made some changes to make it works.

In the tsconfig.app.json add the line

"src/polyfills.ts"

in the files array.

In the angular.json file, transform the polyfills array to be a string:

"polyfills": "src/polyfills.ts"

Then create a file named polyfills.ts with the content:

import 'zone.js'

in the src folder.

You can now serve the application.

Angular14 doesn't seems to support the new schema, but I've not managed to find any article about it. If you want to benefit from all the new stuff I suggest you to update your project to the latest LTS (At the time of this answer, the version 15).

EDIT:

My tests were done using NodeJS version 18.16.0 and NPM 9.6.7

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论