Skip to content

ng build --prod: Cannot find module css-loader/index.js?sourcemap&minimize #4292

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
francisoud opened this issue Jan 30, 2017 · 20 comments
Closed

Comments

@francisoud
Copy link

francisoud commented Jan 30, 2017

Versions.

ng --version
angular-cli: 1.0.0-beta.21
node: 6.9.1
os: win32 x64

Repro steps.

npm cache clean
npm install --no-optional
ng build --prod

The log given by the failure.

Module build failed: Error: Cannot find module '/var/bamboo/xml-data/build-dir/JOB1/node_modules/css-loader/index.js?sourcemap&minimize'
        at Function.Module._resolveFilename (module.js:469:15)
        at Function.Module._load (module.js:417:25)
...

Mention any other details that might be useful.

Well actually I found the reason and the fix (it just for the record if anyone has the same issue...):
In [email protected] / package.json this following line:

"extract-text-webpack-plugin": "^2.0.0-beta.4",

Resolved to different incompatible extract-text-webpack-plugin version:

25 jan. 17

Changed to:

30 jan. 17

Solution

Do a npm shrinkwrap but if it's too late, add the following line to your package.json:

"devDependencies": {
    "extract-text-webpack-plugin": "2.0.0-beta.5"
},

Another problem

After fixing this you may get a lodash error:

Error in bail mode: [default] /var/bamboo/xml-data/build-dir/JOB1/node_modules/@types/lodash/index.d.ts:245:24 
Cannot find name 'Partial'.

change the dependency to

"@types/lodash": "4.14.50",

make sure you don't take the v4.14.51

ps: Don't forget to delete you node_modules and run npm cache clean before npm install

@techtreet
Copy link

The fix suggested above didn't work for me on 1.0.0-beta.21, I continue to see the following

cannot find module css-loader

@castamir
Copy link

castamir commented Jan 31, 2017

@ngtools/[email protected] broke it, adding "@ngtools/webpack": "1.2.3", to package.json for temporal workaround fixed if me... for now...

@cnvillegaschavez
Copy link

steps
npm install -g [email protected]
npm cache clean
npm install

"devDependencies": {
"extract-text-webpack-plugin": "2.0.0-beta.5",
"webpack": "2.2.0-rc.3",
"@types/lodash": "4.14.50",
"@ngtools/webpack": "1.2.3"
},

@byungjuJin
Copy link

extract-text-webpack-plugin is upgraded to 2.0.0-rc.2.
just add "extract-text-webpack-plugin": "2.0.0-beta.5" works for me.
Thanks!

@castamir
Copy link

castamir commented Feb 1, 2017

after "double" npm install I've got nprm error UNMET DEPENDENCIES.

I fixed all dependencies by specifying these dependencies explicitly:

{
        "@ngtools/webpack": "1.1.5",
        "extract-text-webpack-plugin": "2.0.0-beta.5",
        "webpack": "2.1.0-beta.25",
        "loader-runner": "2.2.0",
        "tsickle": "0.2.4",
        "source-map-support": "0.4.10"
}

most important are extract-text-webpack-plugin and webpack itself

Note: I've digged these dependencies from cli-beta.21

@techtreet
Copy link

techtreet commented Feb 1, 2017

The "ng build --prod" works for me now with the list posted by castamir above, thanks for everyone in this thread.

{
"@ngtools/webpack": "1.1.5",
"extract-text-webpack-plugin": "2.0.0-beta.5",
"webpack": "2.1.0-beta.25",
"loader-runner": "2.2.0",
"tsickle": "0.2.4",
"source-map-support": "0.4.10",
"angular-cli": "1.0.0-beta.21"
}

NOTE: I didn't have to even install angular-cli on my npm, but I am just declaring it in the package.json as shown above. I uninstalled my angular cli using "npm uninstall -g angular-cli" and "npm cache clean". Now I am able to build prod using package.json script task itself that runs the angular-cli based build with in the local confines of package.json and not at global level installed angular-cli.

"scripts": {
         "build:prod": "ng build --prod"
}

@hydra1983
Copy link

hydra1983 commented Feb 6, 2017

All the solutions above doesn't work for me.
I added

{
    "extract-text-webpack-plugin": "2.0.0-beta.5",
}

But 2.0.0-rc.3 still be installed.

peerDependencies WARNING [[email protected]] in /var/jenkins_home/workspace/xxx-dev/xxx-web2-pipeline/node_modules/.2.0.0-rc.3@extract-text-webpack-plugin requires a peer of webpack@^2.2.0 but [email protected] was installed

ls -la node_modules/|grep extract
drwxr-xr-x    4 root root     4096 Feb  6 06:43 .1.0.1@postcss-modules-extract-imports
drwxr-xr-x    3 root root     4096 Feb  6 06:43 .2.0.0-beta.5@extract-text-webpack-plugin
drwxr-xr-x    5 root root     4096 Feb  6 06:43 .2.0.0-rc.3@extract-text-webpack-plugin
lrwxrwxrwx    1 root root       41 Feb  6 06:43 extract-text-webpack-plugin -> .2.0.0-beta.5@extract-text-webpack-plugin
lrwxrwxrwx    1 root root       38 Feb  6 06:43 postcss-modules-extract-imports -> .1.0.1@postcss-modules-extract-imports

After I run

rm -rf node_modules/.2.0.0-rc.3@extract-text-webpack-plugin

And re-build production again, it works.

node version: 6.2.0
npm version: 3.8.9

@castamir
Copy link

castamir commented Feb 6, 2017

make a fresh new npm install and then hit npm ls extract-text-webpack-plugin to see which package depends on it

@techtreet
Copy link

techtreet commented Feb 6, 2017

Can anyone from angular-cli DEV community please comment if there are any plans for this to be fixed on the newer version so that we don't have to use this hack with older version? I see the same issue happening even with "@angular/cli": "1.0.0-beta.29". Is this already fixed with #4435 ? I also see something relevant at http://stackoverflow.com/questions/42076879/fallbackloader-option-has-been-deprecated-replace-with-fallback

@bertolo1988
Copy link

+1

@mbrezovsky
Copy link

+1

@GeorgeZhai
Copy link

+1

@mikekeda
Copy link

mikekeda commented Mar 9, 2017

+1

@techtreet
Copy link

With @angular/cli: 1.0.0-rc.1, I see this is now fixed. Just create a new project out of RC1 version and try to use the generated package.json and it should work. Pasted my package.json below and this works now. I dont see the issue anymore. I was referring #4435 and understood that they have taken care of this in beta 31 fix itself.

"dependencies": {
"@angular/common": "^2.4.0",
"@angular/compiler": "^2.4.0",
"@angular/core": "^2.4.0",
"@angular/forms": "^2.4.0",
"@angular/http": "^2.4.0",
"@angular/platform-browser": "^2.4.0",
"@angular/platform-browser-dynamic": "^2.4.0",
"@angular/router": "^3.4.0",
"core-js": "^2.4.1",
"rxjs": "^5.1.0",
"zone.js": "^0.7.6"
},
"devDependencies": {
"@angular/cli": "1.0.0-rc.1",
"@angular/compiler-cli": "^2.4.0",
"@types/jasmine": "2.5.38",
"@types/node": "~6.0.60",
"codelyzer": "~2.0.0",
"jasmine-core": "~2.5.2",
"jasmine-spec-reporter": "~3.2.0",
"karma": "~1.4.1",
"karma-chrome-launcher": "~2.0.0",
"karma-cli": "~1.0.1",
"karma-jasmine": "~1.1.0",
"karma-jasmine-html-reporter": "^0.2.2",
"karma-coverage-istanbul-reporter": "^0.2.0",
"protractor": "~5.1.0",
"ts-node": "~2.0.0",
"tslint": "~4.4.2",
"typescript": "~2.0.0"
}

@mikekeda
Copy link

@itsforbabu Thanks
I updated angular/cli to 1.0.0-rc.1, and now it works

@bertolo1988
Copy link

@mikekeda How have you updated to rc.1 ? Last pubished version is still beta.28.3.

@deebloo
Copy link
Contributor

deebloo commented Mar 11, 2017

https://www.npmjs.com/package/@angular/cli

npm uninstall -g angular-cli
npm cache clear
npm install -g @angular/cli@latest

@filipesilva
Copy link
Contributor

Closing as fixed in latest releases.

@bertolo1988
Copy link

Why not publish under angular-cli as usual?

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 6, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests