我在运行示例Angular 应用程序的脚本时遇到问题。该应用程序是使用Nodejs 16.10.0和npm版本6.23.2创建的,Angular CLI为14.2.10。我将我的nodejs更新为16.13.0和npm版本8.1.0。Angular CLI为15.0.2。此问题仅在运行我的自定义脚本时出现。ng serve和ng build工作正常。下面是错误,我无法找到错误的原因。
我正在尝试运行命令npm run test:precheckin
错误:
> angular-app@0.0.0 test:precheckin
> npx npm-run-all build:int
Watching D:\angular migration POC\Angular14App\AngularApp and all sub-directories not excluded by your .gitignore. Will not monitor dotfiles.
Found & ignored ./.angular ; is listed in .gitignore
Found & ignored ./.vscode ; is listed in .gitignore
Found & ignored ./dist ; is listed in .gitignore
Found & ignored ./node_modules ; is listed in .gitignore
Found & ignored ./src ; is listed in .gitignore
Found & ignored ./angular.json ; is listed in .gitignore
Found & ignored ./karma.conf.js ; is listed in .gitignore
Found & ignored ./package-lock.json ; is listed in .gitignore
Found & ignored ./package.json ; is listed in .gitignore
Found & ignored ./README.md ; is listed in .gitignore
Found & ignored ./tsconfig.app.json ; is listed in .gitignore
Found & ignored ./tsconfig.json ; is listed in .gitignore
Found & ignored ./tsconfig.spec.json ; is listed in .gitignore
Starting: test
node:internal/modules/cjs/loader:936
throw err;
^
Error: Cannot find module 'D:\angular migration POC\Angular14App\AngularApp\test'
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
at Function.Module._load (node:internal/modules/cjs/loader:778:27)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
at node:internal/main/run_main_module:17:47 {
code: 'MODULE_NOT_FOUND',
requireStack: []
}
Watching D:\angular migration POC\Angular14App\AngularApp and all sub-directories not excluded by your .gitignore. Will not monitor dotfiles.
Found & ignored ./.angular ; is listed in .gitignore
Found & ignored ./.vscode ; is listed in .gitignore
Found & ignored ./dist ; is listed in .gitignore
Found & ignored ./node_modules ; is listed in .gitignore
Found & ignored ./src ; is listed in .gitignore
Found & ignored ./angular.json ; is listed in .gitignore
Found & ignored ./karma.conf.js ; is listed in .gitignore
Found & ignored ./package-lock.json ; is listed in .gitignore
Found & ignored ./package.json ; is listed in .gitignore
Found & ignored ./README.md ; is listed in .gitignore
Found & ignored ./tsconfig.app.json ; is listed in .gitignore
Found & ignored ./tsconfig.json ; is listed in .gitignore
Found & ignored ./tsconfig.spec.json ; is listed in .gitignore
Starting: build:int
node:internal/modules/cjs/loader:936
throw err;
^
Error: Cannot find module 'D:\angular migration POC\Angular14App\AngularApp\build:int'
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
at Function.Module._load (node:internal/modules/cjs/loader:778:27)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
at node:internal/main/run_main_module:17:47 {
code: 'MODULE_NOT_FOUND',
requireStack: []
}
包.json
{
"name": "angular-app",
"version": "0.0.0",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"watch": "ng build --watch --configuration int",
"build:int": "npm run high:mem -- build --configuration=int",
"test:precheckin": "npx npm-run-all test build:int",
"high:mem": "node --max_old_space_size=8192 ./node_modules/@angular/cli/bin/ng",
"test": "ng test"
},
"private": true,
"dependencies": {
"@angular/animations": "~13.3.0",
"@angular/common": "~13.3.0",
"@angular/compiler": "~13.3.0",
"@angular/core": "~13.3.0",
"@angular/forms": "~13.3.0",
"@angular/platform-browser": "~13.3.0",
"@angular/platform-browser-dynamic": "~13.3.0",
"@angular/router": "~13.3.0",
"rxjs": "~7.5.0",
"tslib": "^2.3.0",
"zone.js": "~0.11.4"
},
"devDependencies": {
"@angular-devkit/build-angular": "~13.3.10",
"@angular/cli": "~13.3.10",
"@angular/compiler-cli": "~13.3.0",
"@types/jasmine": "~3.10.0",
"@types/node": "^12.11.1",
"jasmine-core": "~4.0.0",
"karma": "~6.3.0",
"karma-chrome-launcher": "~3.1.0",
"karma-coverage": "~2.1.0",
"karma-jasmine": "~4.0.0",
"karma-jasmine-html-reporter": "~1.7.0",
"typescript": "~4.6.2"
}
}
1条答案
按热度按时间yhived7q1#
问题是
npm-run-all
似乎不能与npx
一起工作请参见以下讨论:
https://github.com/mysticatea/npm-run-all/issues/209
https://github.com/mysticatea/npm-run-all/issues/218
这看起来是一个很好的解决方法https://github.com/mysticatea/npm-run-all/issues/209#issuecomment-847926286:
它看起来像这样:
但我只会安装
npm-run-all
型
然后