今天运行npm run build:prod时,我收到一个奇怪的错误。
"build:prod": "ng build --prod --aot=false --preserve-symlinks"
错误就像..
92% chunk asset optimizationC:\Projects\Latest_Feb26\ASSURE.OdyssEYGen2\FrontEnd\OdyssEY-UI-Host\node_modules\clean-css
\lib\reader\input-source-map-tracker.js:37
if (originalPosition.line === null && line > 1 && selectorFallbacks > 0) {
^
TypeError: Cannot read property 'line' of undefined
at originalPositionFor (C:\Projects\Latest_Feb26\ASSURE.OdyssEYGen2\FrontEnd\OdyssEY-UI-Host\node_modules\clean-css\
lib\reader\input-source-map-tracker.js:37:23)
构建工作总是很好,不知道为什么我今天收到这个奇怪的错误。
我确实删除了node_modules,npm i和npm run build:prod
任何人都可以帮助我吗?
Visual Studio代码中的OUTPUT选项卡上还有一些内容:
Failed to load the ESLint library for the document c:\Projects\Latest_Feb26\ASSURE.OdyssEYGen2\FrontEnd\OdyssEY-UI-Host\node_modules\clean-css\lib\reader\input-source-map-tracker.js
To use ESLint in this workspace please install eslint using 'npm install eslint' or globally using 'npm install -g eslint'.
You need to reopen the workspace after installing eslint.
由于
答案 0 :(得分:0)
用以下代码替换node_modules / clean-css / lib / reader / input-source-tracker.js中的代码;)
var SourceMapConsumer = require('source-map').SourceMapConsumer;
function inputSourceMapTracker() {
var maps = {};
return {
all: all.bind(null, maps),
isTracking: isTracking.bind(null, maps),
originalPositionFor: originalPositionFor.bind(null, maps),
track: track.bind(null, maps)
};
}
function all(maps) {
return maps;
}
function isTracking(maps, source) {
return source in maps;
}
function originalPositionFor(maps, metadata, range, selectorFallbacks) {
var line = metadata[0];
var column = metadata[1];
var source = metadata[2];
var position = {
line: line,
column: column + range
};
var originalPosition;
while (!originalPosition && position.column > column) {
position.column--;
originalPosition = maps[source].originalPositionFor(position);
}
if (originalPosition && originalPosition.line === null && line > 1 && selectorFallbacks > 0) {
return originalPositionFor(maps, [line - 1, column, source], range, selectorFallbacks - 1);
}
return (originalPosition && originalPosition.line) !== null ?
toMetadata(originalPosition) :
metadata;
}
function toMetadata(asHash) {
if(asHash){
return [asHash.line, asHash.column, asHash.source];
}
}
function track(maps, source, data) {
maps[source] = new SourceMapConsumer(data);
}
module.exports = inputSourceMapTracker;