生成离子管道错误

Generate Ionic Pipe error

使用 ionic cli 生成管道文件时

ionic g pipe example

导致以下错误:

Error: ENOENT: no such file or directory, open '<PROJECT_PATH>/src/PIPES/example.module.ts'
    at Object.fs.openSync (fs.js:652:18)
    at Object.fs.writeFileSync (fs.js:1299:33)
    at createCommonModule (/home/future/Projects/SmartUpCode/smartupcrm-mobile/node_modules/@ionic/app-scripts/dist/generators/util.js:77:10)
    at Object.<anonymous> (<PROJECT_PATH>/node_modules/@ionic/app-scripts/dist/generators/util.js:238:29)
    at step (<PROJECT_PATH>e/node_modules/@ionic/app-scripts/dist/generators/util.js:32:23)
    at Object.next (<PROJECT_PATH>/node_modules/@ionic/app-scripts/dist/generators/util.js:13:53)
    at fulfilled (<PROJECT_PATH>/node_modules/@ionic/app-scripts/dist/generators/util.js:4:58)
    at <anonymous>

生成管道时出现此“Error: ENOENT: no such file or directory,”错误是因为在本机 ionic config.js 文件中使用了错误的目录路径。

node_modules > @ionic > app-scripts > dist > util > config.js file

问题可以通过在生成 example.module.ts 文件的路径中将大写 'PIPES' 名称更改为小写 'pipes' 来解决,如下所示;

context.pipesNgModulePath = path_1.resolve(getConfigValue(context, '--pipesNgModulePath', null, Constants.ENV_PIPES_NG_MODULE_PATH, Constants.ENV_PIPES_NG_MODULE_PATH.toLowerCase(), path_1.join(context.srcDir, 'PIPES', 'pipes.module.ts')));

(context.srcDir, 'pipes', 'pipes.module.ts')

然后效果很好...