-
Notifications
You must be signed in to change notification settings - Fork 18
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
TypeError: Os.tmpDir is not a function when plugin is active on all serverless commands #18
Comments
same error here, any solutions? |
@marcosfede as a temporary solution; I switched to node 8 with command |
This is caused by a deprecation of tmpDir in node. You can read more about it here: https://stackoverflow.com/questions/40913034/ My solution was to do the following:
Works perfectly, but I just have to remember to do this everytime I npm install |
@aelzeiny Could you update the dependencies to use |
👍 I am having the same issue, need to update |
@DiogoTheCoder Sorry, I'm not a maintainer of this code-base, and I only used it once for a side-project when I ran into this issue. If I were the one to make the change I'll probably break something else. I just thought my comment would be helpful. |
Yep, me too. |
In some caes Windows 10 uses tmpDir ( with camel case ) so you can solve this issue like this var isWin = process.platform === "win32"; if(isWin){ |
this will only be a problem if you use node > 12 pin your project to use node <= 12 with nvm echo 'lts/erbium' > .nvmrc |
NodeJS 10 support will be ending very soon. |
'NodeJS 10 support will be ending very soon' very true 'lts/erbium' is Node 12 and good for a little longer The serverless framework has issues & PRs referring to os.tmpDir so it shouldn't be a problem much longer |
This may be helpful for anyone that stumbles across this in the future. An automated version of @ananunaki 's solution: (I have only tested on Darwin) // fix-sls-offline.js
const fs = require('fs');
const LINE_NUMBER = 6;
const FILE_LOCATION = 'node_modules/hapi/lib/defaults.js'
const INJECT_FIX_STRING = `
var isWin = process.platform === "win32";
var isLinux = process.platform === "linux";
var isDarwin = process.platform === "darwin";
if (isDarwin || isLinux) {
Os.tmpDir = Os.tmpdir;
} else if (isWin) {
Os.tmpDir = os.tmpDir;
}
`
let data = fs.readFileSync(FILE_LOCATION)
if (data.includes(INJECT_FIX_STRING)) {
console.log("Skipping fix injection, already exists.")
} else {
data = data.toString().split("\n");
data.splice(LINE_NUMBER, 0, INJECT_FIX_STRING);
let text = data.join("\n");
fs.writeFile(FILE_LOCATION, text, (err) => {
if (err) {
return console.log(err);
} else {
return console.log('Injected fix successfully')
}
});
}
// package.json
"scripts": {
"deploy": "serverless deploy",
"start": "serverless offline start",
"prestart": "node fix-sls-offline.js"
} |
adding |
I am having trouble with this and hoping someone could help me out. I have downgraded to node 12 but i am still have the same proplem. I tried to locate the "hapi/lib" file but there is no "lib" file. Any ideas? |
where you add this? |
question
Should I add this as a new line 6 (did not work for me) or on line 5 next to the |
@Aiperikurenkeeva both ways should work. Probably a bit cleaner to add |
Worked like a charm. Thank you very much :) |
I am using a fresh serverless install (via brew) and when I enable the serverless-offline-python any sls function I try, produces the error below. If I comment the plugin out in the serverless.yml then everything works again (well not testing my Python-based lambda offline).
MacOS: 10.15.3
Node Version: 14.0.0
Framework Version: 1.68.0
Plugin Version: 3.6.6
SDK Version: 2.3.0
Components Version: 2.30.1
The text was updated successfully, but these errors were encountered: