Reputation: 31
I am using vue to write a chrome extension.I initialize my project through vue-cli-plugiin-chrome-extension
.
I use promise
in my background.js
.When i run npm run build-watch
,it throw the erro like this
Module not found: Error: Can't resolve './node_modules/core-js/fn/promise' in 'C:\Users\COD002\OneDrive\桌面\vue-test\test\src\entry'
(node:12064) UnhandledPromiseRejectionWarning: Error: Build failed with errors.
at Watching.handler (C:\Users\COD002\OneDrive\桌面\vue-test\test\node_modules\@vue\cli-service\lib\commands\build\index.js:207:23)
at C:\Users\COD002\OneDrive\桌面\vue-test\test\node_modules\webpack\lib\Watching.js:290:9
at Hook.eval [as callAsync] (eval at create (C:\Users\COD002\OneDrive\桌面\vue-test\test\node_modules\tapable\lib\HookCodeFactory.js:33:10), <anonymous>:24:1)
at Hook.CALL_ASYNC_DELEGATE [as _callAsync] (C:\Users\COD002\OneDrive\桌面\vue-test\test\node_modules\tapable\lib\Hook.js:18:14)
at Watching._done (C:\Users\COD002\OneDrive\桌面\vue-test\test\node_modules\webpack\lib\Watching.js:287:28)
at C:\Users\COD002\OneDrive\桌面\vue-test\test\node_modules\webpack\lib\Watching.js:209:21
at Compiler.emitRecords (C:\Users\COD002\OneDrive\桌面\vue-test\test\node_modules\webpack\lib\Compiler.js:919:5)
at C:\Users\COD002\OneDrive\桌面\vue-test\test\node_modules\webpack\lib\Watching.js:187:22
at C:\Users\COD002\OneDrive\桌面\vue-test\test\node_modules\webpack\lib\Compiler.js:885:14
at Hook.eval [as callAsync] (eval at create (C:\Users\COD002\OneDrive\桌面\vue-test\test\node_modules\tapable\lib\HookCodeFactory.js:33:10), <anonymous>:6:1)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:12064) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)
(node:12064) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
I have tried update core-js
and download the whole node_modules
again.But it doesn't work.
My package.json
{
"name": "test",
"version": "0.1.0",
"private": true,
"scripts": {
"serve": "vue-cli-service serve",
"build": "vue-cli-service build",
"lint": "vue-cli-service lint",
"build-watch": "vue-cli-service --env.NODE_ENV=development build-watch --mode development"
},
"dependencies": {
"vue": "^3.2.13"
},
"devDependencies": {
"@babel/core": "^7.12.16",
"@babel/eslint-parser": "^7.12.16",
"@vue/cli-plugin-babel": "~5.0.0",
"@vue/cli-plugin-eslint": "~5.0.0",
"@vue/cli-service": "~5.0.0",
"core-js": "^2.6.12",
"eslint": "^7.32.0",
"eslint-plugin-vue": "^8.0.3",
"vue-cli-plugin-chrome-extension-cli": "~1.1.4"
},
"eslintConfig": {
"root": true,
"env": {
"node": true,
"webextensions": true
},
"extends": [
"plugin:vue/vue3-essential",
"eslint:recommended"
],
"parserOptions": {
"parser": "@babel/eslint-parser"
},
"rules": {}
},
"browserslist": [
"> 1%",
"last 2 versions",
"not dead",
"not ie 11"
]
}
Upvotes: 1
Views: 814
Reputation: 31
I have fixed this problem myself by chance. I deleted the node_modules
folder again and ran npm install
. It was warning me that Prototype Pollution in async
, so I
followed guidance to fix it. Then the program didn't throw the error.
Upvotes: 1