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
Cannot set property to of [object String] which has only a getter #752
Comments
When I used the version less than or equal to 0.6.0, it ran successfully |
Why are you trying to set the Full stack trace? |
I don't know why. I just used the code above in gulp. |
I have no problems: // gulpfile.js
var fs = require('fs');
var path = require('path');
var gulp = require('gulp');
var shelljs = require('shelljs');
gulp.task('clean', () => {
if (fs.existsSync(path.resolve('lib'))) {
shelljs.rm('-rf', path.resolve('lib'));
}
}); $ ls -d lib/ &>/dev/null && echo 'The folder exists'
The folder exists
$ gulp clean
[21:57:20] Using gulpfile ~/foobar/gulpfile.js
[21:57:20] Starting 'clean'...
[21:57:20] Finished 'clean' after 6.33 ms
$ ls -d lib/ &>/dev/null || echo 'The folder was deleted'
The folder was deleted Node v6.7.0 |
Can you try to repro with my steps? |
I'm sorry that I can't reply you in time due to too many affairs to deal with recently. Create a NPM module, directory is as follows
s-tool.js #!/usr/bin/env node
const program = require('commander');
program.on('--help', () => {
console.log(' Usage:');
console.log(' clean');
});
program.parse(process.argv);
const task = program.args[0];
if (!task) {
program.help();
} else {
const gulp = require('gulp');
require('../index');
gulp.start(task);
} index.js const path = require('path');
const fs = require('fs-extra');
const shelljs = require('shelljs');
const gulp = require('gulp');
function resolveCwd() {
const args = [].slice.call(arguments, 0);
args.unshift(process.cwd());
return path.join.apply(path, args);
};
// clean
gulp.task('clean', () => {
if (fs.existsSync(resolveCwd('lib'))) {
shelljs.rm('-rf', resolveCwd('lib'));
}
});
// other task ... package.json {
"name": "s-tool",
"version": "1.0.0",
"bin": {
"s-tool": "./bin/s-tool.js"
},
"scripts": {
"pub": "npm publish"
},
"license": "ISC",
"dependencies": {
"commander": "~2.9.0",
"shelljs": "~0.7.8",
"fs-extra": "^0.26.7",
"gulp": "^3.9.1"
}
} useage: $ npm install -g s-tool $ cd workspace If the folder lib exists, the error occurs. However, when I used the version less than or equal to 0.6.0, it ran successfully |
I still have no repro on Linux. Please provide a full stack trace from when you reproduce. Also, please give a repro case using no other modules (only shelljs). I don't know if those other modules are tampering with us. |
@ilex0208 any update? |
Closing due to lack of response. Please ping this thread again if you can provide more information. |
I found some package modify prototype of |
@zombieJ we do not modify the prototype unless you import with |
hi @nfischer , |
The package you mean is |
I don't believe there's anything for us to address here, kindly raise this issue with the |
Node version (or tell us if you're using electron or some other framework):6.11
ShellJS version (the most recent version/Github branch you see the bug on):0.7.8
Operating system:windows10
Description of the bug:Cannot set property to of [object String] which has only a getter
Example ShellJS command to reproduce the error: shelljs.rm
the error details is:
pipeMethods: [ 'cat','exec','grep', 'head', 'sed','sort','tail', 'to', 'toEnd', 'uniq' ]
cmd cat
cmd exec
cmd grep
cmd head
cmd sed
cmd sort
cmd tail
cmd to
error TypeError: Cannot set property to of [object String] which has only a getter
cmd toEnd
cmd uniq
that is to say, the 'to' method cannot set property!
The text was updated successfully, but these errors were encountered: