错误:Angular启动/node_modules/@types/node/index.d.ts (20,1): Invalid 'reference' directive syntax.
E:\web-project\angulardemo>npm run start > angulardemo@0.0.0 start E:\web-project\angulardemo > ng serve fallbackLoader option has been deprecated - replace with "fallback" loader option has been deprecated - replace with "use" fallbackLoader option has been deprecated - replace with "fallback" loader option has been deprecated - replace with "use" fallbackLoader option has been deprecated - replace with "fallback" loader option has been deprecated - replace with "use" fallbackLoader option has been deprecated - replace with "fallback" loader option has been deprecated - replace with "use" ** NG Live Development Server is running on http://localhost:4200. ** 10% building modules 6/6 modules 0 active(node:13196) DeprecationWarning: loaderUtils.parseQuery() received a non-string value which can be problematic, see https://github.com/webpack/loader-utils/issues/56 parseQuery() will be replaced with getOptions() in the next major version of loader-utils. (Use `node --trace-deprecation ...` to show where the warning was created) Hash: 77bf3ed9d657b78ba2d8 Time: 6707ms chunk {0} polyfills.bundle.js, polyfills.bundle.map (polyfills) 248 kB {4} [initial] [rendered] chunk {1} main.bundle.js, main.bundle.map (main) 4.01 kB {3} [initial] [rendered] chunk {2} styles.bundle.js, styles.bundle.map (styles) 9.71 kB {4} [initial] [rendered] chunk {3} vendor.bundle.js, vendor.bundle.map (vendor) 2.64 MB [initial] [rendered] chunk {4} inline.bundle.js, inline.bundle.map (inline) 0 bytes [entry] [rendered] ERROR in E:/web-project/angulardemo/node_modules/@types/node/index.d.ts (20,1): Invalid 'reference' directive syntax. webpack: Failed to compile.
解决:E:\web-project\angulardemo\node_modules\@types\node\index.d.ts 去掉3个\\\斜杆修改成 2个斜杠如下面:
// Type definitions for Node.js 6.14 // Project: http://nodejs.org/ // Definitions by: Microsoft TypeScript <https://github.com/Microsoft> // DefinitelyTyped <https://github.com/DefinitelyTyped> // Wilco Bakker <https://github.com/WilcoBakker> // Thomas Bouldin <https://github.com/inlined> // Sebastian Silbermann <https://github.com/eps1lon> // Alorel <https://github.com/Alorel> // Hoàng Văn Khải <https://github.com/KSXGitHub> // Sander Koenders <https://github.com/Archcry> // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // NOTE: These definitions support NodeJS and TypeScript 3.2 and above. // NOTE: TypeScript version-specific augmentations can be found in the following paths: // - ~/base.d.ts - Shared definitions common to all TypeScript versions // - ~/index.d.ts - Definitions specific to TypeScript 2.1 // - ~/ts3.2/index.d.ts - Definitions specific to TypeScript 3.2 // Reference required types from the default lib: // <reference lib="es2015" /> // Base definitions for all NodeJS modules that are not specific to any version of TypeScript: // <reference path="base.d.ts" /> // TypeScript 3.2-specific augmentations:
修改完再次运行:
E:\web-project\angulardemo>npm run start > angulardemo@0.0.0 start E:\web-project\angulardemo > ng serve fallbackLoader option has been deprecated - replace with "fallback" loader option has been deprecated - replace with "use" fallbackLoader option has been deprecated - replace with "fallback" loader option has been deprecated - replace with "use" fallbackLoader option has been deprecated - replace with "fallback" loader option has been deprecated - replace with "use" fallbackLoader option has been deprecated - replace with "fallback" loader option has been deprecated - replace with "use" ** NG Live Development Server is running on http://localhost:4200. ** 10% building modules 6/6 modules 0 active(node:13168) DeprecationWarning: loaderUtils.parseQuery() received a non-string value which can be problematic, see https://github.com/webpack/loader-utils/issues/56 parseQuery() will be replaced with getOptions() in the next major version of loader-utils. (Use `node --trace-deprecation ...` to show where the warning was created) Hash: 77bf3ed9d657b78ba2d8 Time: 6129ms chunk {0} polyfills.bundle.js, polyfills.bundle.map (polyfills) 248 kB {4} [initial] [rendered] chunk {1} main.bundle.js, main.bundle.map (main) 4.01 kB {3} [initial] [rendered] chunk {2} styles.bundle.js, styles.bundle.map (styles) 9.71 kB {4} [initial] [rendered] chunk {3} vendor.bundle.js, vendor.bundle.map (vendor) 2.64 MB [initial] [rendered] chunk {4} inline.bundle.js, inline.bundle.map (inline) 0 bytes [entry] [rendered] webpack: Compiled successfully.