Angular-cli: ng build library throw error "BUILD ERROR returned value of `file` must be a string"

Created on 10 Jun 2018  路  3Comments  路  Source: angular/angular-cli

- [x] bug report -> please search issues before submitting
- [ ] feature request

Area

- [x] devkit
- [ ] schematics

Versions

Node: v8.9.4
NPM: 6.0.1
Windows 10

Repro steps

Step 1
ng new ngx-mark6 --style=scss --routing --skip-install

Step 2
ng generate library mark6-lib --prefix mark6

Step 3
ng build mark6-lib

The log given by the failure

C:\Users\sven\PhpstormProjects\ngx-mark6>ng build mark6-lib
Building Angular Package
Building entry point 'mark6-lib'
Rendering Stylesheets

BUILD ERROR
returned value of `file` must be a string
Error: returned value of `file` must be a string
    at options.error (C:\Users\sven\PhpstormProjects\ngx-mark6\node_modules\node-sass\lib\index.js:291:26)

returned value of `file` must be a string
Error: returned value of `file` must be a string
    at options.error (C:\Users\sven\PhpstormProjects\ngx-mark6\node_modules\node-sass\lib\index.js:291:26)

Desired functionality

Want to build a external library

Mention any other details that might be useful

The Repo to check relevant things i maybe forgot: https://github.com/DevMonkeysDE/ngx-mark6

And by the way: Sometimes npm install work and sometimes not. Remember this is a totaly clean CLI generated Project... Error Message:

C:\Users\sven\PhpstormProjects\ngx-mark6>npm install
npm WARN [email protected] No repository field.
npm WARN [email protected] No license field.

npm ERR! path C:\Users\sven\PhpstormProjects\ngx-mark6\node_modules\@types\jasminewd2\package.json.3702476408
npm ERR! code EPERM
npm ERR! errno -4048
npm ERR! syscall rename
npm ERR! Error: EPERM: operation not permitted, rename 'C:\Users\sven\PhpstormProjects\ngx-mark6\node_modules\@types\ja
sminewd2\package.json.3702476408' -> 'C:\Users\sven\PhpstormProjects\ngx-mark6\node_modules\@types\jasminewd2\package.j
son'
npm ERR!  { Error: EPERM: operation not permitted, rename 'C:\Users\sven\PhpstormProjects\ngx-mark6\node_modules\@types
\jasminewd2\package.json.3702476408' -> 'C:\Users\sven\PhpstormProjects\ngx-mark6\node_modules\@types\jasminewd2\packag
e.json'
npm ERR!   cause:
npm ERR!    { Error: EPERM: operation not permitted, rename 'C:\Users\sven\PhpstormProjects\ngx-mark6\node_modules\@typ
es\jasminewd2\package.json.3702476408' -> 'C:\Users\sven\PhpstormProjects\ngx-mark6\node_modules\@types\jasminewd2\pack
age.json'
npm ERR!      errno: -4048,
npm ERR!      code: 'EPERM',
npm ERR!      syscall: 'rename',
npm ERR!      path: 'C:\\Users\\sven\\PhpstormProjects\\ngx-mark6\\node_modules\\@types\\jasminewd2\\package.json.37024
76408',
npm ERR!      dest: 'C:\\Users\\sven\\PhpstormProjects\\ngx-mark6\\node_modules\\@types\\jasminewd2\\package.json' },
npm ERR!   stack: 'Error: EPERM: operation not permitted, rename \'C:\\Users\\sven\\PhpstormProjects\\ngx-mark6\\node_m
odules\\@types\\jasminewd2\\package.json.3702476408\' -> \'C:\\Users\\sven\\PhpstormProjects\\ngx-mark6\\node_modules\\@types\\jasminewd2\\package.json\'',
npm ERR!   errno: -4048,
npm ERR!   code: 'EPERM',
npm ERR!   syscall: 'rename',
npm ERR!   path: 'C:\\Users\\sven\\PhpstormProjects\\ngx-mark6\\node_modules\\@types\\jasminewd2\\package.json.3702476408',
npm ERR!   dest: 'C:\\Users\\sven\\PhpstormProjects\\ngx-mark6\\node_modules\\@types\\jasminewd2\\package.json',
npm ERR!   parent: 'ngx-mark6' }
npm ERR!
npm ERR! The operation was rejected by your operating system.
npm ERR! It's possible that the file was already in use (by a text editor or antivirus),
npm ERR! or that you lack permissions to access it.
npm ERR!
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator (though this is not recommended).

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\sven\AppData\Roaming\npm-cache\_logs\2018-06-09T22_53_39_829Z-debug.log

If i retry it, it after 1 or 2 more trys works. I just post this error log in case this have anything to do with my problem.

library

Most helpful comment

Okay i solved this. The problem was that there was in my component a @import on a scss file that does not exist. I generated a css project and change the settings in angular.json to scss. Thinked the problem comes because this.

Its maybe possible to output in this case a better error message?

All 3 comments

Okay i solved this. The problem was that there was in my component a @import on a scss file that does not exist. I generated a css project and change the settings in angular.json to scss. Thinked the problem comes because this.

Its maybe possible to output in this case a better error message?

Heya, can you report this in https://github.com/dherges/ng-packagr please? Libraries are built using ng-packagr, and thats where issues specific to it should be reported.

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._

Was this page helpful?
0 / 5 - 0 ratings