我在Windows环境中使用节点js,angular cli,我最近克隆了我正在处理我的Windows机器的项目,但是它没有提供以下erorr,因为项目在我的运行完美linux机器,可能的原因是什么?
ng serve
** NG Live Development Server is listening on localhost:4200, open your browser on http://localhost:4200 **
12% building modules 22/38 modules 16 active ...tend\node_modules\strip-ansi\index.jsError: No module factory available for dependency type: ContextElementDependency
at Compilation.addModuleDependencies (node_modules\@angular\cli\node_modules\webpack\lib\Compilation.js:206:21)
at Compilation.processModuleDependencies (node_modules\@angular\cli\node_modules\webpack\lib\Compilation.js:195:8)
at _this.buildModule.err (node_modules\@angular\cli\node_modules\webpack\lib\Compilation.js:336:13)
at building.forEach.cb (node_modules\@angular\cli\node_modules\webpack\lib\Compilation.js:140:27)
at Array.forEach (native)
at callback (node_modules\@angular\cli\node_modules\webpack\lib\Compilation.js:140:13)
at module.build (node_modules\@angular\cli\node_modules\webpack\lib\Compilation.js:167:11)
at resolveDependencies (node_modules\@angular\cli\node_modules\webpack\lib\ContextModule.js:133:4)
at ContextModule.result.resolveDependencies (node_modules\@ngtools\webpack\src\plugin.js:229:25)
at ContextModule.build (node_modules\@angular\cli\node_modules\webpack\lib\ContextModule.js:103:8)
at Compilation.buildModule (node_modules\@angular\cli\node_modules\webpack\lib\Compilation.js:142:10)
at factoryCallback (node_modules\@angular\cli\node_modules\webpack\lib\Compilation.js:325:11)
at node_modules\@angular\cli\node_modules\webpack\lib\ContextModuleFactory.js:96:12
at node_modules\tapable\lib\Tapable.js:204:11
at done.then (node_modules\@ngtools\webpack\src\plugin.js:231:28)
13% building modules 27/43 modules 16 active ...lar\material\@angular\material.es5.js
node_modules\@angular\cli\node_modules\webpack\lib\Compilation.js:265
if(_this.profile) {
^
TypeError: Cannot read property 'profile' of null
at factoryCallback (node_modules\@angular\cli\node_modules\webpack\lib\Compilation.js:265:13)
at factory (node_modules\@angular\cli\node_modules\webpack\lib\NormalModuleFactory.js:253:5)
at applyPluginsAsyncWaterfall (node_modules\@angular\cli\node_modules\webpack\lib\NormalModuleFactory.js:99:14)
at node_modules\tapable\lib\Tapable.js:204:11
at NormalModuleFactory.params.normalModuleFactory.plugin (node_modules\@angular\cli\node_modules\webpack\lib\CompatibilityPlugin.js:52:5)
at NormalModuleFactory.applyPluginsAsyncWaterfall (node_modules\tapable\lib\Tapable.js:208:13)
at resolver (node_modules\@angular\cli\node_modules\webpack\lib\NormalModuleFactory.js:74:11)
at process.nextTick (node_modules\@angular\cli\node_modules\webpack\lib\NormalModuleFactory.js:205:8)
at _combinedTickCallback (internal/process/next_tick.js:73:7)
at process._tickCallback (internal/process/next_tick.js:104:9)
我还尝试在Windows上的ubuntu上通过bash运行ng服务,它给出了以下错误
npm start
> businessops@0.0.0 start
> ng serve
EINVAL: invalid argument, uv_interface_addresses
Error: EINVAL: invalid argument, uv_interface_addresses
at Error (native)
at Object.lib.networkInterfaces (node_modules/macaddress/index.js:31:21)
at Object.lib.one (node_modules/macaddress/index.js:79:26)
at Object.<anonymous> (node_modules/uniqid/index.js:15:77)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (node_modules/postcss-filter-plugins/dist/index.js:9:15)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
npm ERR! Linux 3.4.0+
npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "start"
npm ERR! node v6.11.1
npm ERR! npm v3.10.10
npm ERR! code ELIFECYCLE
npm ERR! businessops@0.0.0 start: `ng serve`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the businessops@0.0.0 start script 'ng serve'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the businessops package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! ng serve
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs businessops
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls businessops
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! npm-debug.log
以下是npm-debug.log的内容:
0 info it worked if it ends with ok
1 verbose cli [ '/usr/bin/nodejs', '/usr/bin/npm', 'start' ]
2 info using npm@3.10.10
3 info using node@v6.11.1
4 verbose run-script [ 'prestart', 'start', 'poststart' ]
5 info lifecycle businessops@0.0.0~prestart: businessops@0.0.0
6 silly lifecycle businessops@0.0.0~prestart: no script for prestart, continuing
7 info lifecycle businessops@0.0.0~start: businessops@0.0.0
8 verbose lifecycle businessops@0.0.0~start: unsafe-perm in lifecycle true
9 verbose lifecycle businessops@0.0.0~start: PATH: /usr/lib/node_modules/npm/bin/node-gyp-bin:node_modules/.bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games
10 verbose lifecycle businessops@0.0.0~start: CWD:
11 silly lifecycle businessops@0.0.0~start: Args: [ '-c', 'ng serve' ]
12 silly lifecycle businessops@0.0.0~start: Returned: code: 1 signal: null
13 info lifecycle businessops@0.0.0~start: Failed to exec start script
14 verbose stack Error: businessops@0.0.0 start: `ng serve`
14 verbose stack Exit status 1
14 verbose stack at EventEmitter.<anonymous> (/usr/lib/node_modules/npm/lib/utils/lifecycle.js:255:16)
14 verbose stack at emitTwo (events.js:106:13)
14 verbose stack at EventEmitter.emit (events.js:191:7)
14 verbose stack at ChildProcess.<anonymous> (/usr/lib/node_modules/npm/lib/utils/spawn.js:40:14)
14 verbose stack at emitTwo (events.js:106:13)
14 verbose stack at ChildProcess.emit (events.js:191:7)
14 verbose stack at maybeClose (internal/child_process.js:891:16)
14 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)
15 verbose pkgid businessops@0.0.0
16 verbose cwd /mnt/c/Users/saif/Documents/Angular/Businessops/frontend
17 error Linux 3.4.0+
18 error argv "/usr/bin/nodejs" "/usr/bin/npm" "start"
19 error node v6.11.1
20 error npm v3.10.10
21 error code ELIFECYCLE
22 error businessops@0.0.0 start: `ng serve`
22 error Exit status 1
23 error Failed at the businessops@0.0.0 start script 'ng serve'.
23 error Make sure you have the latest version of node.js and npm installed.
23 error If you do, this is most likely a problem with the businessops package,
23 error not with npm itself.
23 error Tell the author that this fails on your system:
23 error ng serve
23 error You can get information on how to open an issue for this project with:
23 error npm bugs businessops
23 error Or if that isn't available, you can get their info via:
23 error npm owner ls businessops
23 error There is likely additional logging output above.
24 verbose exit [ 1, true ]
答案 0 :(得分:0)
我遇到了同样的问题。这是WLS中的已知错误(请参阅https://github.com/Microsoft/WSL/issues/1343)。
以下是解决方法:https://github.com/Microsoft/WSL/issues/1343#issuecomment-279781472
// hack for Ubuntu on Windows try { require('os').networkInterfaces(); } catch (e) { require('os').networkInterfaces = () => ({}); }
将该代码放在一个文件中,并在webpack.config.js文件中要求它。
在我的情况下,错误来自node_modules / macaddress / index.js,只是在开始时添加此代码解决了问题。
似乎问题已在最新的Windows 10版本中修复。